File: rpl_gtid_replay_relaylog.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 (78 lines) | stat: -rw-r--r-- 3,182 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
############################################################################
# Bug #17650326  MYSQLBINLOG PRINTS INVALID SQL FROM RELAY LOGS WHEN GTID IS
# ENABLED
# Problem: Replaying a relaylog which ends with GTID_LOG_EVENT causes error
# "ERROR 1790 (HY000) @@SESSION.GTID_NEXT cannot be changed by a client that
# owns a GTID. The client owns <UUID:GNO>. Ownership is released on COMMIT
# or ROLLBACK."
#
# Steps to reproduce:
#  1) Stop IO thread after reading gtid_log_event (relaylog 1 contains
#      GTID_LOG_EVENT at the end)
#  2) Restart IO thread which rotates relaylog file (relaylog 2)
#  3) Replay relaylog1's 'mysqlbinlog' output against 'mysql' client tool,
#     it should not cause any problems.
#  4) Replay (relaylog1 + relaylog2)'s 'mysqlbinlog' output against
#     'mysql' client tool, it should not cause any problems.
#
############################################################################
--source include/have_debug.inc
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc

# Initial setup
CREATE TABLE t1(i INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--source include/sync_slave_sql_with_master.inc
--let MYSQLD_DATADIR=`select @@datadir`
SET @save_debug=@@global.debug;

# Step 1: Stop I/O thread after reading GTID_LOG_EVENT
# This will leave the relaylog in incomplete state(i.e., it ends
# with GTID_LOG_EVENT)
SET GLOBAL DEBUG='+d,stop_io_after_reading_gtid_log_event';

--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES (2);

--source include/rpl_connection_slave.inc
--source include/wait_for_slave_io_to_stop.inc
--let $relay_file1 = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 )

--let $auto_pos = query_get_value( SHOW SLAVE STATUS, Auto_Position, 1 )
--let $assert_text= Slave MASTER_AUTO_POSITION should be enabled for this test
--let $assert_cond= $auto_pos= 1
--source include/assert.inc

# Step 2: Restart I/O thread and execute the pending INSERT(2)
SET GLOBAL DEBUG= @save_debug;
--source include/start_slave.inc

--source include/rpl_connection_master.inc
--source include/sync_slave_sql_with_master.inc
--let $relay_file2 = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 )

# Step 3: Replay the incomplete Relaylog's mysqlbinlog output against mysql and see that
# there are no issues.
DROP TABLE t1;
RESET MASTER;
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/$relay_file1 | $MYSQL -uroot -S$SLAVE_MYSOCK -P$SLAVE_MYPORT

--let $assert_text= Check that there is one tuple in the table
--let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 where i=1, Val, 1] = 1
--source include/assert.inc

# Step 4: Concat two relay logs and then replay mysqlbinlog ouput against mysql and see
# that there are no issues.
DROP TABLE t1;
RESET MASTER;
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/$relay_file1 $MYSQLD_DATADIR/$relay_file2 | $MYSQL -uroot -S$SLAVE_MYSOCK -P$SLAVE_MYPORT

--let $assert_text= Check that there are two tuples in the table
--let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 where i=1 or i=2, Val, 1] = 2
--source include/assert.inc

# Cleanup
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/rpl_end.inc