File: rpl_gtids_restart_slave_io_lost_trx.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 (127 lines) | stat: -rw-r--r-- 4,202 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#
# This test will verify if the slave SQL thread and the slave IO thread behave
# correctly when the IO thread is restarted in the middle of a transaction.
#
# It is expected that the IO thread will retrieve again the partial transaction
# from the beginning and that the SQL thread will rollback the partially
# retrieved transaction before applying the fully retrieved one.
#
# This test will insert some data in the master and then will stop the slave
# IO thread right after queuing an event of a given type, starting the IO
# thread again to fully retrieve the partially received transaction.
#
####
# param: $using_mts   1 if the test is running with multi-threaded slave


# As this test depends on the use of a User_var_log_event in a DML statement
# we have to use statement based replication.
--source include/have_binlog_format_statement.inc
--source include/force_restart.inc
# Enable auto_position protocol
--let $use_gtids= 1
--let $rpl_gtid_utils= 1
--source include/master-slave.inc
# Test should run only on debug build
source include/have_debug.inc;
source include/have_debug_sync.inc;

# Initial setup
--connection master
CREATE TABLE t1(i INT) ENGINE=InnoDB;
# The following "FLUSH LOGS" will make the master to clear the "created" flag
# of the Format Description events in the next binlog files (and also in
# their replicated versions in the slave's relaylog).
FLUSH LOGS;
--source include/sync_slave_sql_with_master.inc
SET @save_debug=@@global.debug;

#
# Actual test starts here.
#
# Test will do the following five iterations
#     1.Stop I/O thread after reading GTID_LOG_EVENT
#     2.Stop I/O thread after reading QUERY_LOG_EVENT
#     3.Stop I/O thread after reading XID_LOG_EVENT
#        which is equal to I/O thread sync with master
#     4.Stop I/O thread after the gtid is in EXECUTED_GTID_SET
#       i.e., after sync slave sql thread with master.
#     5.Stop I/O thread after reading USER_VAR_LOG_EVENT
# and after that make sure there are no missing gtid events
# i.e., we will verify this by doing diff between master:t1,
# slave:t1.

--let $i=1
while ($i <= 5)
{
  if ($i == 1)
  {
    SET GLOBAL DEBUG='d,stop_io_after_reading_gtid_log_event';
  }
  if ($i == 2)
  {
    SET GLOBAL DEBUG='d,stop_io_after_reading_query_log_event';
  }
  if ($i == 3)
  {
    # Stopping sql thread to make sure that case 3 is not equal to case 4.
    --source include/stop_slave_sql.inc
    SET GLOBAL DEBUG='d,stop_io_after_reading_xid_log_event';
  }
  if ($i == 5)
  {
    SET GLOBAL DEBUG='d,stop_io_after_reading_user_var_log_event';
  }
  --connection master
  BEGIN;
  --eval INSERT INTO t1 VALUES ($i)
  --eval SET @v= $i * 100
  --eval INSERT INTO t1 VALUES (@v)
  COMMIT;
  --connection slave
  if ($i == 4)
  {
    --connection master
    --source include/sync_slave_sql_with_master.inc
    --source include/stop_slave_io.inc
  }
  --source include/wait_for_slave_io_to_stop.inc
  # Remove the debug point and restart the slave threads
  SET GLOBAL DEBUG= @save_debug;

  --source include/start_slave_io.inc

  if ($i == 2)
  {
    if ($using_mts == 1)
    {
      --source include/rpl_connection_master.inc
      --source include/sync_slave_sql_with_master.inc
      --let $applied_trxs_gtid= query_get_value(SELECT COUNT(LAST_APPLIED_TRANSACTION) FROM performance_schema.replication_applier_status_by_worker WHERE CHAR_LENGTH(LAST_APPLIED_TRANSACTION) > 0, COUNT(LAST_APPLIED_TRANSACTION), 1)
      --let $assert_text= Assert that the monitoring recorded the transaction applied by only one worker
      --let $assert_cond= "$applied_trxs_gtid" = 1
      --source include/assert.inc
    }
  }

  if ($i == 3)
  {
    --source include/start_slave_sql.inc
  }
  # Do one more insert on master and then sync slave with master (to make sure
  # that re-replicating the events are done successfully.
  --connection master
  --eval INSERT INTO t1 VALUES ($i)
  --source include/sync_slave_sql_with_master.inc
  # Now compare master and slave's t1 table data
  # to prove that there are no missing gtids.
  --let diff_tables= master:t1, slave:t1
  --source include/diff_tables.inc
  --inc $i
}

# Cleanup
--connection master
DROP TABLE t1;

--source include/rpl_end.inc