| 1 |
include/rpl_init.inc [topology=1->2->3] |
| 2 |
# |
| 3 |
# Initialize test data |
| 4 |
# Ensure that all slaves has master_last_event_time == NULL |
| 5 |
# |
| 6 |
connection server_1; |
| 7 |
SET STATEMENT sql_log_bin=0 FOR create table t1 (a int) engine=innodb; |
| 8 |
include/save_master_pos.inc |
| 9 |
connection server_2; |
| 10 |
SET STATEMENT sql_log_bin=0 FOR create table t1 (a int) engine=innodb; |
| 11 |
connection server_3; |
| 12 |
SET STATEMENT sql_log_bin=0 FOR create table t1 (a int) engine=innodb; |
| 13 |
# |
| 14 |
# Test *_last_event_time is updated at proper place. |
| 15 |
# Master_last_event_time should be updated by the IO thread when reading |
| 16 |
# in a new transaction from the primary. |
| 17 |
# Slave_last_event_time should be updated by the SQL thread |
| 18 |
# 1) immediately upon seeing the first transaction if the replica is |
| 19 |
# starting fresh, or |
| 20 |
# 2) after committing a transaction. |
| 21 |
# |
| 22 |
connection server_2; |
| 23 |
start slave io_thread; |
| 24 |
include/sync_io_with_master.inc |
| 25 |
master_time: (should be empty) |
| 26 |
slave_time: (should be empty) |
| 27 |
# Sleep 2s to create a time gap between the header events (i.e. |
| 28 |
# Format_description and Gtid_list) and the transaction event to allow |
| 29 |
# proving that header events should not update |
| 30 |
# (Master|Slave)_last_event_time |
| 31 |
connect server_1_1,127.0.0.1,root,,test,$SERVER_MYPORT_1,; |
| 32 |
set @@timestamp= TIMESTAMP; |
| 33 |
insert into t1 values (0); |
| 34 |
include/save_master_pos.inc |
| 35 |
connection server_2; |
| 36 |
include/sync_io_with_master.inc |
| 37 |
# For the first event, at execution start, Slave_last_event_time should |
| 38 |
# be updated to be 1 second prior to the time that the first transaction |
| 39 |
# was binlogged on the primary. This is to represent that the slave is |
| 40 |
# otherwise up-to-date. Note the table is locked to prevent the |
| 41 |
# transaction from committing (and thereby progressing |
| 42 |
# Slave_last_event_time to represent commit-time). |
| 43 |
connect server_2_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; |
| 44 |
lock tables t1 write; |
| 45 |
connection server_2; |
| 46 |
start slave sql_thread; |
| 47 |
# Waiting for replica to start executing the transaction (yet get stuck on the table lock) |
| 48 |
connection server_2_2; |
| 49 |
unlock tables; |
| 50 |
connection server_2; |
| 51 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 52 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 53 |
# |
| 54 |
# Test that changes are properly applied by server_2 and server_3 |
| 55 |
# |
| 56 |
connection server_1; |
| 57 |
include/save_master_pos.inc |
| 58 |
connection server_2; |
| 59 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 60 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 61 |
include/save_master_pos.inc |
| 62 |
# Show that the server_2 received the insert from master |
| 63 |
select * from t1; |
| 64 |
a |
| 65 |
0 |
| 66 |
master <> NULL; Should be 1 |
| 67 |
1 |
| 68 |
master_time == slave_time ; Should be 1 |
| 69 |
1 |
| 70 |
connection server_3; |
| 71 |
include/start_slave.inc |
| 72 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 73 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 74 |
# Show that the server_3 received the insert from master |
| 75 |
select * from t1; |
| 76 |
a |
| 77 |
0 |
| 78 |
master <> NULL; Should be 1 |
| 79 |
1 |
| 80 |
master_time == slave_time ; Should be 1 |
| 81 |
1 |
| 82 |
include/stop_slave.inc |
| 83 |
connection server_1; |
| 84 |
# |
| 85 |
# Test simple insert |
| 86 |
# |
| 87 |
connection server_1; |
| 88 |
insert into t1 values (1+sleep(3)); |
| 89 |
# |
| 90 |
# Test that changes are properly applied by server_2 and server_3 |
| 91 |
# |
| 92 |
connection server_1; |
| 93 |
include/save_master_pos.inc |
| 94 |
connection server_2; |
| 95 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 96 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 97 |
include/save_master_pos.inc |
| 98 |
# Show that the server_2 received the insert from master |
| 99 |
select * from t1; |
| 100 |
a |
| 101 |
0 |
| 102 |
1 |
| 103 |
master <> NULL; Should be 1 |
| 104 |
1 |
| 105 |
master_time == slave_time ; Should be 1 |
| 106 |
1 |
| 107 |
connection server_3; |
| 108 |
include/start_slave.inc |
| 109 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 110 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 111 |
# Show that the server_3 received the insert from master |
| 112 |
select * from t1; |
| 113 |
a |
| 114 |
0 |
| 115 |
1 |
| 116 |
master <> NULL; Should be 1 |
| 117 |
1 |
| 118 |
master_time == slave_time ; Should be 1 |
| 119 |
1 |
| 120 |
include/stop_slave.inc |
| 121 |
connection server_1; |
| 122 |
# |
| 123 |
# Test insert with forced time |
| 124 |
# |
| 125 |
SET TIMESTAMP=unix_timestamp("2000-01-01"); |
| 126 |
insert into t1 values (2+sleep(3)); |
| 127 |
SET TIMESTAMP=DEFAULT; |
| 128 |
# |
| 129 |
# Test that changes are properly applied by server_2 and server_3 |
| 130 |
# |
| 131 |
connection server_1; |
| 132 |
include/save_master_pos.inc |
| 133 |
connection server_2; |
| 134 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 135 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 136 |
include/save_master_pos.inc |
| 137 |
# Show that the server_2 received the insert from master |
| 138 |
select * from t1; |
| 139 |
a |
| 140 |
0 |
| 141 |
1 |
| 142 |
2 |
| 143 |
master <> NULL; Should be 1 |
| 144 |
1 |
| 145 |
master_time == slave_time ; Should be 1 |
| 146 |
1 |
| 147 |
connection server_3; |
| 148 |
include/start_slave.inc |
| 149 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 150 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 151 |
# Show that the server_3 received the insert from master |
| 152 |
select * from t1; |
| 153 |
a |
| 154 |
0 |
| 155 |
1 |
| 156 |
2 |
| 157 |
master <> NULL; Should be 1 |
| 158 |
1 |
| 159 |
master_time == slave_time ; Should be 1 |
| 160 |
1 |
| 161 |
include/stop_slave.inc |
| 162 |
connection server_1; |
| 163 |
# |
| 164 |
# Test multi-transaction |
| 165 |
# |
| 166 |
begin; |
| 167 |
insert into t1 values (3+sleep(3)); |
| 168 |
insert into t1 values (4+sleep(3)); |
| 169 |
commit; |
| 170 |
# |
| 171 |
# Test that changes are properly applied by server_2 and server_3 |
| 172 |
# |
| 173 |
connection server_1; |
| 174 |
include/save_master_pos.inc |
| 175 |
connection server_2; |
| 176 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 177 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 178 |
include/save_master_pos.inc |
| 179 |
# Show that the server_2 received the insert from master |
| 180 |
select * from t1; |
| 181 |
a |
| 182 |
0 |
| 183 |
1 |
| 184 |
2 |
| 185 |
3 |
| 186 |
4 |
| 187 |
master <> NULL; Should be 1 |
| 188 |
1 |
| 189 |
master_time == slave_time ; Should be 1 |
| 190 |
1 |
| 191 |
connection server_3; |
| 192 |
include/start_slave.inc |
| 193 |
include/wait_for_slave_param.inc [Relay_Master_Log_File] |
| 194 |
include/wait_for_slave_param.inc [Exec_Master_Log_Pos] |
| 195 |
# Show that the server_3 received the insert from master |
| 196 |
select * from t1; |
| 197 |
a |
| 198 |
0 |
| 199 |
1 |
| 200 |
2 |
| 201 |
3 |
| 202 |
4 |
| 203 |
master <> NULL; Should be 1 |
| 204 |
1 |
| 205 |
master_time == slave_time ; Should be 1 |
| 206 |
1 |
| 207 |
include/stop_slave.inc |
| 208 |
connection server_1; |
| 209 |
# cleanup |
| 210 |
connection server_3; |
| 211 |
include/start_slave.inc |
| 212 |
connection server_1; |
| 213 |
drop table t1; |
| 214 |
include/rpl_end.inc |
| 215 |
# End of master_last_event_time_row |