| 1 |
# |
| 2 |
# ==== Purpose ==== |
| 3 |
# |
| 4 |
# This test checks if the immediate_commit_timestamp (ICT) and the |
| 5 |
# original_commit_timestamp (OCT) are generated and replicated correctly in a |
| 6 |
# server_1 (Master) -> server_2 -> server_3 topology, all of them mysql-5.8+ |
| 7 |
# |
| 8 |
# ==== Implementation ==== |
| 9 |
# |
| 10 |
# Considering the previously mentioned replication chain, we make the following |
| 11 |
# assertions: |
| 12 |
# 1) original_commit_timestamp is the same across all servers |
| 13 |
# 2) On the original server, original_commit_timestamp = immediate_commit_timestamp. |
| 14 |
# 2) the immediate_commit_timestamp increases as we go down in the topology. |
| 15 |
# This assertions are performed in two examples of DDL statements and three |
| 16 |
# different DML statements. |
| 17 |
# |
| 18 |
# |
| 19 |
# ==== References ==== |
| 20 |
# |
| 21 |
# WL#7319 Infrastructure for correct replication lag monitoring |
| 22 |
|
| 23 |
|
| 24 |
# Legend: |
| 25 |
# OCT: original_commit_timestamp |
| 26 |
# ICT: immediate_commit_timestamp |
| 27 |
|
| 28 |
--source include/have_binlog_format_row.inc |
| 29 |
|
| 30 |
# Establish the line topology. |
| 31 |
--let $rpl_topology=1->2, 2->3 |
| 32 |
--source include/rpl_init.inc |
| 33 |
|
| 34 |
--let $rpl_connection_name= server_1 |
| 35 |
--source include/rpl_connection.inc |
| 36 |
CREATE TABLE t1 (a INT); |
| 37 |
--source include/rpl_sync.inc |
| 38 |
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1) |
| 39 |
--let $gtid= $server_uuid:1 |
| 40 |
# |
| 41 |
# The GTID event is generated at the commit time. Hence the time of |
| 42 |
# execution of GTID event will be almost the Commit time.This test |
| 43 |
# checks that the ICT value is greater than or equal to the |
| 44 |
# time of execution of the GTID event. |
| 45 |
# |
| 46 |
--source include/get_gtid_time.inc |
| 47 |
--let $readable= 1 |
| 48 |
--let $only_time= 1 |
| 49 |
--source include/get_immediate_commit_timestamp.inc |
| 50 |
--let $readable= 0 |
| 51 |
|
| 52 |
--disable_query_log |
| 53 |
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/ |
| 54 |
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time) |
| 55 |
--enable_query_log |
| 56 |
|
| 57 |
# since these variables will not be redefined anywhere, they will only be |
| 58 |
# declared here |
| 59 |
--let $server_1= server_1 |
| 60 |
--let $server_2= server_2 |
| 61 |
--let $server_3= server_3 |
| 62 |
--source extra/rpl_tests/rpl_timestamps_line_topology.inc |
| 63 |
--let $OCT1= $original_commit_timestamp |
| 64 |
|
| 65 |
--let $rpl_connection_name= server_1 |
| 66 |
--source include/rpl_connection.inc |
| 67 |
INSERT INTO t1 VALUES(1); |
| 68 |
--source include/rpl_sync.inc |
| 69 |
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1) |
| 70 |
--let $gtid= $server_uuid:2 |
| 71 |
|
| 72 |
--source include/get_gtid_time.inc |
| 73 |
--let $readable= 1 |
| 74 |
--source include/get_immediate_commit_timestamp.inc |
| 75 |
--let $readable= 0 |
| 76 |
|
| 77 |
--disable_query_log |
| 78 |
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/ |
| 79 |
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time) |
| 80 |
--enable_query_log |
| 81 |
|
| 82 |
--source extra/rpl_tests/rpl_timestamps_line_topology.inc |
| 83 |
--let $OCT2= $original_commit_timestamp |
| 84 |
|
| 85 |
--let $rpl_connection_name= server_1 |
| 86 |
--source include/rpl_connection.inc |
| 87 |
UPDATE t1 SET a=2; |
| 88 |
--source include/rpl_sync.inc |
| 89 |
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1) |
| 90 |
--let $gtid= $server_uuid:3 |
| 91 |
|
| 92 |
--source include/get_gtid_time.inc |
| 93 |
--let $readable= 1 |
| 94 |
--source include/get_immediate_commit_timestamp.inc |
| 95 |
--let $readable= 0 |
| 96 |
|
| 97 |
--disable_query_log |
| 98 |
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/ |
| 99 |
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time) |
| 100 |
--enable_query_log |
| 101 |
|
| 102 |
--source extra/rpl_tests/rpl_timestamps_line_topology.inc |
| 103 |
--let $OCT3= $original_commit_timestamp |
| 104 |
|
| 105 |
--let $rpl_connection_name= server_1 |
| 106 |
--source include/rpl_connection.inc |
| 107 |
DELETE FROM t1 WHERE a=2; |
| 108 |
--source include/rpl_sync.inc |
| 109 |
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1) |
| 110 |
--let $gtid= $server_uuid:4 |
| 111 |
|
| 112 |
--source include/get_gtid_time.inc |
| 113 |
--let $readable= 1 |
| 114 |
--source include/get_immediate_commit_timestamp.inc |
| 115 |
--let $readable= 0 |
| 116 |
|
| 117 |
--disable_query_log |
| 118 |
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/ |
| 119 |
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time) |
| 120 |
--enable_query_log |
| 121 |
|
| 122 |
--source extra/rpl_tests/rpl_timestamps_line_topology.inc |
| 123 |
--let $OCT4= $original_commit_timestamp |
| 124 |
|
| 125 |
--let $rpl_connection_name= server_1 |
| 126 |
--source include/rpl_connection.inc |
| 127 |
DROP TABLE t1; |
| 128 |
--source include/rpl_sync.inc |
| 129 |
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1) |
| 130 |
--let $gtid= $server_uuid:5 |
| 131 |
|
| 132 |
--source include/get_gtid_time.inc |
| 133 |
--let $readable= 1 |
| 134 |
--source include/get_immediate_commit_timestamp.inc |
| 135 |
--let $readable= 0 |
| 136 |
--let $only_time= 0 |
| 137 |
|
| 138 |
--disable_query_log |
| 139 |
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/ |
| 140 |
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time) |
| 141 |
--enable_query_log |
| 142 |
|
| 143 |
--source extra/rpl_tests/rpl_timestamps_line_topology.inc |
| 144 |
--let $OCT5= $original_commit_timestamp |
| 145 |
|
| 146 |
--echo # 2. Verify that the Original_commit_timestamps are correct. |
| 147 |
# Due to windows lower resolution timestamps, it may happen that the timestamps |
| 148 |
# are equal. |
| 149 |
|
| 150 |
# Check if the platform is windows to select the appropriate assert condition |
| 151 |
--let $is_windows= 0 |
| 152 |
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`) |
| 153 |
{ |
| 154 |
--let $is_windows= 1 |
| 155 |
} |
| 156 |
|
| 157 |
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction.. |
| 158 |
if ($is_windows) |
| 159 |
{ |
| 160 |
--let $assert_cond= $OCT1 <= $OCT2 |
| 161 |
} |
| 162 |
if (!$is_windows) |
| 163 |
{ |
| 164 |
--let $assert_cond= $OCT1 < $OCT2 |
| 165 |
} |
| 166 |
--source include/assert.inc |
| 167 |
|
| 168 |
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction.. |
| 169 |
if ($is_windows) |
| 170 |
{ |
| 171 |
--let $assert_cond= $OCT2 <= $OCT3 |
| 172 |
} |
| 173 |
if (!$is_windows) |
| 174 |
{ |
| 175 |
--let $assert_cond= $OCT2 < $OCT3 |
| 176 |
} |
| 177 |
--source include/assert.inc |
| 178 |
|
| 179 |
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction.. |
| 180 |
if ($is_windows) |
| 181 |
{ |
| 182 |
--let $assert_cond= $OCT3 <= $OCT4 |
| 183 |
} |
| 184 |
if (!$is_windows) |
| 185 |
{ |
| 186 |
--let $assert_cond= $OCT3 < $OCT4 |
| 187 |
} |
| 188 |
--source include/assert.inc |
| 189 |
|
| 190 |
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction.. |
| 191 |
if ($is_windows) |
| 192 |
{ |
| 193 |
--let $assert_cond= $OCT4 <= $OCT5 |
| 194 |
} |
| 195 |
if (!$is_windows) |
| 196 |
{ |
| 197 |
--let $assert_cond= $OCT4 < $OCT5 |
| 198 |
} |
| 199 |
--source include/assert.inc |
| 200 |
|
| 201 |
--source include/rpl_end.inc |