Debian Codegraph @

mysql-test/suite/binlog/t/binlog_truncate_kill.test

raw
1 ###############################################################################
2 # Bug#17942050:KILL OF TRUNCATE TABLE WILL LEAD TO BINARY LOG WRITTEN WHILE
3 # ROWS REMAINS
4 #
5 # Problem:
6 # ========
7 # When truncate table fails while using transactional based engines even
8 # though the operation errors out we still continue and log it to binlog.
9 # Because of this master has data but the truncate will be written to binary
10 # log which will cause inconsistency.
11 #
12 # Test:
13 # =====
14 # Make master to wait in "open_table" call during the execution of truncate
15 # table command and kill the truncate table from other connection. This causes
16 # open table to return an error saying truncate failed during open table. This
17 # statement should not be binlogged.
18 ###############################################################################
19 --source include/have_debug_sync.inc
20 --source include/have_binlog_format_statement.inc
21 --source include/force_myisam_default.inc
22 --source include/have_myisam.inc
23 RESET MASTER;
24 --enable_connect_log
25 --connection default
26 --echo # MERGE is the only remaning non-specialized SE (like NDB or P_S)
27 --echo # which implements TRUNCATE TABLE through handler::truncate().
28 CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, a INT, b INT) ENGINE=MyISAM;
29 CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, a INT, b INT) ENGINE=MERGE UNION=(t0) INSERT_METHOD=LAST;
30 INSERT INTO t1(a, b) VALUES(1,2),(2,4),(3,6),(4,8),(5,10);
31 SET DEBUG_SYNC = "open_and_process_table signal truncate_before_lock wait_for forever";
32 --send TRUNCATE t1
33
34 connect(con1,localhost,root,,);
35 SET DEBUG_SYNC = "now wait_for truncate_before_lock";
36 # Wait for one connection to reach open_and_process_table.
37 --let $show_statement= SHOW PROCESSLIST
38 --let $field= State
39 --let $condition= 'debug sync point: open_and_process_table';
40 --source include/wait_show_condition.inc
41
42 SELECT ((@id := id) - id) FROM information_schema.processlist WHERE processlist.info LIKE '%TRUNCATE t1%' AND state LIKE '%open_and_process_table%';
43 # Test killing from mysql server
44 KILL QUERY @id;
45
46 connection default;
47 --ERROR ER_QUERY_INTERRUPTED
48 --reap
49
50 connection con1;
51 --source include/show_binlog_events.inc
52
53 disconnect con1;
54 --source include/wait_until_disconnected.inc
55 connection default;
56
57 SELECT * FROM t1;
58
59 DROP TABLE t1, t0;
60 SET DEBUG_SYNC= 'RESET';
61 --disable_connect_log