File: rpl_bug26395.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (108 lines) | stat: -rw-r--r-- 3,476 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# ==== Purpose ====
#
# Tests that an autocommitted XA transaction where the master crashes
# just before writing the XID log event is executed correctly.  The
# master rolls back, so the slave should not execute statement.
#
# This test was previously part of rpl_ndb_transaction.test
#
#
# ==== Method ====
#
# We want master to be alive so that it can replicate the statement to
# the slave. So in the test case, we must not crash the
# master. Instead, we fake the crash by just not writing the XID event
# to the binlog. This is done by the @@debug='d,do_not_write_xid'
# flag. This, in turn, requires us to do 'source
# include/have_debug.inc'
#
# So, unlike if the master had crashed, the master *will* execute the
# statement. But the slave should not execute it. Hence, after the
# test is executed, the expected result on master is a table with one
# row, and on slave a table with no rows.
#
# To simulate the slave correctly, we wait until everything up to but
# not including the XID is replicated. This has to be done with
# include/sync_slave_io_with_master.inc, not sync_slave_with_master,
# since the latter waits until the slave *SQL* thread has caught up
# with the master's position, which it will never do.
#
#
# ==== Related bugs ====
#
# BUG#26395: if crash during autocommit update to transactional table on master, slave fails

--source include/not_group_replication_plugin.inc

# have_debug is needed since we use the @@debug variable on master
--source include/have_debug.inc

# test adapts simulation of incomplete transaction that MTS does not tolerate
# when is stopped. So it reacts with an error whereas the single-threaded is fine.
--source include/not_mts_replica_parallel_workers.inc

--source include/master-slave.inc

--echo ==== Initialize ====

--echo [on master]
--connection master

CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
SHOW CREATE TABLE tinnodb;

# do_not_write_xid stops the master from writing an XID event.
set @old_debug= @@debug;
set @@debug= '+d,do_not_write_xid';


--echo ==== Test ====

# Save the position up to which the slave SQL thread should execute.
save_master_pos;

# Execute query and check that the row made it to the table.
INSERT INTO tinnodb VALUES (1);
SELECT * FROM tinnodb ORDER BY a;

# Sync slave's IO thread.
--echo [on slave]
# After the implementation of the transaction boundary parser,
# this sync cannot use GTIDs or else sync will timeout because only
# GTIDs of fully replicated transactions are in the
# Retrieved_Gtid_Set of the slave and, as the last event of the
# transaction never arrives, syncing with GTIDs won't work.
--let ignore_gtids_on_sync= 1
source include/sync_slave_io_with_master.inc;

# Sync slave's SQL thread.
sync_with_master 0;

--echo ==== Verify results on slave ====

source include/stop_slave.inc;

--let $status_items=Slave_IO_State,Last_SQL_Error,Last_IO_Error
--source include/show_slave_status.inc

--let $assert_text= Assert that the slave table has no rows
--let $assert_cond= `SELECT COUNT(*) = 0 FROM tinnodb`
--source include/assert.inc

--echo ==== Clean up ====

# Easiest to clean up master and slave separately, without
# replication, since master and slave are out of sync.

--echo [on master]
connection master;
DROP TABLE tinnodb;
set @@debug= @old_debug;

--echo [on slave]
connection slave;
DROP TABLE tinnodb;

# Warning: do not add more tests here. The binlog is in a bad state.
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc