Skip to content

Commit 060ec5b

Browse files
f4rnhamknielsen
authored andcommitted
MDEV-7130: MASTER_POS_WAIT(log_name,log_pos,timeout,"connection_name") hangs, does not respect the timeout
Changed also arg_count check for connection_name to prevent same bug if fifth argument is introduced in future
1 parent b616991 commit 060ec5b

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

mysql-test/suite/rpl/r/rpl_master_pos_wait.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,26 @@ show slave status;
1818
select master_pos_wait('foo', 98);
1919
master_pos_wait('foo', 98)
2020
NULL
21+
*** MDEV-7130: MASTER_POS_WAIT(log_name,log_pos,timeout,"connection_name") hangs, does not respect the timeout ***
22+
include/stop_slave.inc
23+
reset slave all;
24+
change master 'my_slave' to master_port=MASTER_MYPORT, master_host='127.0.0.1', master_user='root';
25+
set default_master_connection = 'my_slave';
26+
include/start_slave.inc
27+
# Call without connection name -- works (expected -1)
28+
select master_pos_wait('master-bin.000001',1000000,1);
29+
master_pos_wait('master-bin.000001',1000000,1)
30+
-1
31+
set default_master_connection = '';
32+
# Call for non-existing anonymous connection -- works (expected NULL)
33+
select master_pos_wait('master-bin.000001',1000000,1);
34+
master_pos_wait('master-bin.000001',1000000,1)
35+
NULL
36+
# Call with a valid connection name -- hangs before MDEV-7130 fix (expected -1)
37+
select master_pos_wait('master-bin.000001',1000000,1,"my_slave");
38+
master_pos_wait('master-bin.000001',1000000,1,"my_slave")
39+
-1
40+
STOP SLAVE 'my_slave';
41+
RESET SLAVE 'my_slave' ALL;
42+
change master to master_port=MASTER_MYPORT, master_host='127.0.0.1', master_user='root';
2143
include/rpl_end.inc

mysql-test/suite/rpl/t/rpl_master_pos_wait.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,36 @@ echo "*** must be NULL ***";
2525
select master_pos_wait('foo', 98);
2626

2727
# End of 4.1 tests
28+
29+
30+
--echo *** MDEV-7130: MASTER_POS_WAIT(log_name,log_pos,timeout,"connection_name") hangs, does not respect the timeout ***
31+
32+
--connection slave
33+
--source include/stop_slave.inc
34+
reset slave all;
35+
--replace_result $MASTER_MYPORT MASTER_MYPORT
36+
eval change master 'my_slave' to master_port=$MASTER_MYPORT, master_host='127.0.0.1', master_user='root';
37+
set default_master_connection = 'my_slave';
38+
--source include/start_slave.inc
39+
40+
--echo # Call without connection name -- works (expected -1)
41+
select master_pos_wait('master-bin.000001',1000000,1);
42+
43+
set default_master_connection = '';
44+
45+
--echo # Call for non-existing anonymous connection -- works (expected NULL)
46+
select master_pos_wait('master-bin.000001',1000000,1);
47+
48+
--echo # Call with a valid connection name -- hangs before MDEV-7130 fix (expected -1)
49+
select master_pos_wait('master-bin.000001',1000000,1,"my_slave");
50+
51+
STOP SLAVE 'my_slave';
52+
RESET SLAVE 'my_slave' ALL;
53+
54+
--replace_result $MASTER_MYPORT MASTER_MYPORT
55+
eval change master to master_port=$MASTER_MYPORT, master_host='127.0.0.1', master_user='root';
56+
57+
# End of 10.0 tests
58+
2859
--let $rpl_only_running_threads= 1
2960
--source include/rpl_end.inc

sql/item_func.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3943,11 +3943,11 @@ longlong Item_master_pos_wait::val_int()
39433943
}
39443944
#ifdef HAVE_REPLICATION
39453945
longlong pos = (ulong)args[1]->val_int();
3946-
longlong timeout = (arg_count==3) ? args[2]->val_int() : 0 ;
3946+
longlong timeout = (arg_count>=3) ? args[2]->val_int() : 0 ;
39473947
String connection_name_buff;
39483948
LEX_STRING connection_name;
39493949
Master_info *mi;
3950-
if (arg_count == 4)
3950+
if (arg_count >= 4)
39513951
{
39523952
String *con;
39533953
if (!(con= args[3]->val_str(&connection_name_buff)))

0 commit comments

Comments
 (0)