Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5436,6 +5436,12 @@ int do_save_master_pos()
const char *query;
DBUG_ENTER("do_save_master_pos");

if (!mysql)
{
handle_no_active_connection(curr_command, cur_con, &ds_res);
DBUG_RETURN(1);
}

if (mysql_query(mysql, query= "show master status"))
die("failed in 'show master status': %d %s",
mysql_errno(mysql), mysql_error(mysql));
Expand Down Expand Up @@ -13570,7 +13576,11 @@ int main(int argc, char **argv)
case Q_SYNC_WITH_MASTER: do_sync_with_master(command); break;
case Q_SYNC_SLAVE_WITH_MASTER:
{
do_save_master_pos();
if (do_save_master_pos())
{
command->last_argument= command->end;
break;
}
if (*command->first_argument)
select_connection(command);
else
Expand Down
41 changes: 41 additions & 0 deletions mysql-test/suite/rpl/r/rpl_mysqltest_closed_connection.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include/master-slave.inc
[connection master]
# Connected master-position commands still replicate successfully.
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
connection slave;
SELECT * FROM t1;
a
1
connection master;
connect con1,localhost,root,,;
disconnect con1;
# MDEV-13718: report a closed connection without switching to a slave.
ERROR 000000: MariaDB server has gone away
2006
connection="-closed_connection-"
ERROR 000000: MariaDB server has gone away
2006
connection="-closed_connection-"
ERROR 000000: MariaDB server has gone away
2006
connection="-closed_connection-"
# The errors are consumed, and both sync forms still work.
connection master;
INSERT INTO t1 VALUES (2);
connection slave;
SELECT * FROM t1 ORDER BY a;
a
1
2
connection master;
INSERT INTO t1 VALUES (3);
connection slave1;
SELECT * FROM t1 ORDER BY a;
a
1
2
3
connection master;
DROP TABLE t1;
include/rpl_end.inc
41 changes: 41 additions & 0 deletions mysql-test/suite/rpl/t/rpl_mysqltest_closed_connection.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--source include/master-slave.inc

--echo # Connected master-position commands still replicate successfully.
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
--save_master_pos
--connection slave
--sync_with_master
SELECT * FROM t1;

--connection master
--connect (con1,localhost,root,,)
--disconnect con1

--echo # MDEV-13718: report a closed connection without switching to a slave.
--error 2006
--save_master_pos
--echo $mysql_errno
--echo connection="$CURRENT_CONNECTION"
--error 2006
--sync_slave_with_master
--echo $mysql_errno
--echo connection="$CURRENT_CONNECTION"
--error 2006
--sync_slave_with_master slave1
--echo $mysql_errno
--echo connection="$CURRENT_CONNECTION"

--echo # The errors are consumed, and both sync forms still work.
--connection master
INSERT INTO t1 VALUES (2);
--sync_slave_with_master
SELECT * FROM t1 ORDER BY a;
--connection master
INSERT INTO t1 VALUES (3);
--sync_slave_with_master slave1
SELECT * FROM t1 ORDER BY a;

--connection master
DROP TABLE t1;
--source include/rpl_end.inc