Commit 1a62c8a3 authored by Monty's avatar Monty

MDEV-14822 binlog.binlog_killed fails with wrong result

Problem was timing between the thread that was killed and reading the
binary log.

Updated the test to wait until the killed thread was properly terminated
before checking what's in the binary log.

To make check safe, I changed "threads_connected" to be updated after
thd::cleanup() is done, to ensure that all binary logs updates are done
before the variable is changed.  This was mainly done to get the
test deterministic and have now other real influence in how the server
works.
parent 0b597d3a
......@@ -185,90 +185,88 @@ connection con3;
MI: MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 2);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
master-bin.000002 # Gtid_list # # [#-#-#]
master-bin.000002 # Binlog_checkpoint # # master-bin.000001
master-bin.000002 # Binlog_checkpoint # # master-bin.000002
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=3
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 2)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IM: INNODB, MyISAM
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 3);
INSERT INTO t2 VALUES (NULL, 4);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 4)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 3)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IMI: INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 5);
INSERT INTO t2 VALUES (NULL, 6);
INSERT INTO t1 VALUES (NULL, 7);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 6)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 5)
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 7)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
MI2: MyISAM, INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 8);
INSERT INTO t1 VALUES (NULL, 9);
INSERT INTO t2 VALUES (NULL, 10);
INSERT INTO t1 VALUES (NULL, 11);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 8)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 10)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=8
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 9)
master-bin.000002 # Intvar # # INSERT_ID=9
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 1)
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 11)
master-bin.000002 # Query # # ROLLBACK
connection default;
disconnect con1;
......
......@@ -10,6 +10,13 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state
-- source include/not_embedded.inc
#
# Avoid printing binlog checkpoints
#
--let $skip_checkpoint_events=1
###
### bug#22725 : incorrect killed error in binlogged query
###
......@@ -362,16 +369,20 @@ connect (con3, localhost, root,,);
connection con3;
let $ID= `select connection_id()`;
--let $threads_connected=`select variable_value from information_schema.global_status where variable_name="threads_connected"`
--let wait_condition=select variable_value < $threads_connected from information_schema.global_status where variable_name="threads_connected"
--echo MI: MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 2);
#Connection con1 as killer throughout the test
connection con1;
--replace_result $ID ID
--eval KILL $ID
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--source include/wait_condition.inc
--let $binlog_start= 4
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)
......@@ -383,12 +394,13 @@ let $ID= `select connection_id()`;
--echo IM: INNODB, MyISAM
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 3);
INSERT INTO t2 VALUES (NULL, 4);
connection con1;
--replace_result $ID ID
--eval KILL $ID
--source include/wait_condition.inc
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)
......@@ -400,13 +412,14 @@ let $ID= `select connection_id()`;
--echo IMI: INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 5);
INSERT INTO t2 VALUES (NULL, 6);
INSERT INTO t1 VALUES (NULL, 7);
connection con1;
--replace_result $ID ID
--eval KILL $ID
--source include/wait_condition.inc
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc
--let $binlog_killed_pos=query_get_value(SHOW MASTER STATUS, Position, 1)
......@@ -418,14 +431,15 @@ let $ID= `select connection_id()`;
--echo MI2: MyISAM, INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t2 VALUES (NULL, 8);
INSERT INTO t1 VALUES (NULL, 9);
INSERT INTO t2 VALUES (NULL, 10);
INSERT INTO t1 VALUES (NULL, 11);
connection con1;
--replace_result $ID ID
--eval KILL $ID
--source include/wait_condition.inc
--let $binlog_start= $binlog_killed_pos
--source include/show_binlog_events.inc
......
......@@ -2919,16 +2919,17 @@ void unlink_thd(THD *thd)
DBUG_ENTER("unlink_thd");
DBUG_PRINT("enter", ("thd: %p", thd));
thd->cleanup();
thd->add_status_to_global();
unlink_not_visible_thd(thd);
/*
Do not decrement when its wsrep system thread. wsrep_applier is set for
applier as well as rollbacker threads.
*/
if (IF_WSREP(!thd->wsrep_applier, 1))
dec_connection_count(thd->scheduler);
thd->cleanup();
thd->add_status_to_global();
unlink_not_visible_thd(thd);
thd->free_connection();
DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment