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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
#
# ==== Purpose ====
#
# This test checks if the immediate_commit_timestamp (ICT) and the
# original_commit_timestamp (OCT) are generated and replicated correctly in a
# server_1 (Master) -> server_2 -> server_3 topology, all of them mysql-5.8+
#
# ==== Implementation ====
#
# Considering the previously mentioned replication chain, we make the following
# assertions:
# 1) original_commit_timestamp is the same across all servers
# 2) On the original server, original_commit_timestamp = immediate_commit_timestamp.
# 2) the immediate_commit_timestamp increases as we go down in the topology.
# This assertions are performed in two examples of DDL statements and three
# different DML statements.
#
#
# ==== References ====
#
# WL#7319 Infrastructure for correct replication lag monitoring
# Legend:
# OCT: original_commit_timestamp
# ICT: immediate_commit_timestamp
--source include/have_binlog_format_row.inc
# Establish the line topology.
--let $rpl_topology=1->2, 2->3
--source include/rpl_init.inc
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
CREATE TABLE t1 (a INT);
--source include/rpl_sync.inc
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1)
--let $gtid= $server_uuid:1
#
# The GTID event is generated at the commit time. Hence the time of
# execution of GTID event will be almost the Commit time.This test
# checks that the ICT value is greater than or equal to the
# time of execution of the GTID event.
#
--source include/get_gtid_time.inc
--let $readable= 1
--let $only_time= 1
--source include/get_immediate_commit_timestamp.inc
--let $readable= 0
--disable_query_log
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time)
--enable_query_log
# since these variables will not be redefined anywhere, they will only be
# declared here
--let $server_1= server_1
--let $server_2= server_2
--let $server_3= server_3
--source extra/rpl_tests/rpl_timestamps_line_topology.inc
--let $OCT1= $original_commit_timestamp
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
INSERT INTO t1 VALUES(1);
--source include/rpl_sync.inc
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1)
--let $gtid= $server_uuid:2
--source include/get_gtid_time.inc
--let $readable= 1
--source include/get_immediate_commit_timestamp.inc
--let $readable= 0
--disable_query_log
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time)
--enable_query_log
--source extra/rpl_tests/rpl_timestamps_line_topology.inc
--let $OCT2= $original_commit_timestamp
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
UPDATE t1 SET a=2;
--source include/rpl_sync.inc
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1)
--let $gtid= $server_uuid:3
--source include/get_gtid_time.inc
--let $readable= 1
--source include/get_immediate_commit_timestamp.inc
--let $readable= 0
--disable_query_log
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time)
--enable_query_log
--source extra/rpl_tests/rpl_timestamps_line_topology.inc
--let $OCT3= $original_commit_timestamp
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DELETE FROM t1 WHERE a=2;
--source include/rpl_sync.inc
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1)
--let $gtid= $server_uuid:4
--source include/get_gtid_time.inc
--let $readable= 1
--source include/get_immediate_commit_timestamp.inc
--let $readable= 0
--disable_query_log
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time)
--enable_query_log
--source extra/rpl_tests/rpl_timestamps_line_topology.inc
--let $OCT4= $original_commit_timestamp
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;
--source include/rpl_sync.inc
--let $server_uuid= query_get_value(select @@global.server_uuid, @@global.server_uuid, 1)
--let $gtid= $server_uuid:5
--source include/get_gtid_time.inc
--let $readable= 1
--source include/get_immediate_commit_timestamp.inc
--let $readable= 0
--let $only_time= 0
--disable_query_log
--replace_regex /cast(.* as time)/cast('XX:YY:ZZ' as time) >= cast('XX:YY:ZZ' as time)/
--eval select cast('$immediate_commit_timestamp' as time) >= cast('$gtid_time' as time)
--enable_query_log
--source extra/rpl_tests/rpl_timestamps_line_topology.inc
--let $OCT5= $original_commit_timestamp
--echo # 2. Verify that the Original_commit_timestamps are correct.
# Due to windows lower resolution timestamps, it may happen that the timestamps
# are equal.
# Check if the platform is windows to select the appropriate assert condition
--let $is_windows= 0
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`)
{
--let $is_windows= 1
}
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction..
if ($is_windows)
{
--let $assert_cond= $OCT1 <= $OCT2
}
if (!$is_windows)
{
--let $assert_cond= $OCT1 < $OCT2
}
--source include/assert.inc
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction..
if ($is_windows)
{
--let $assert_cond= $OCT2 <= $OCT3
}
if (!$is_windows)
{
--let $assert_cond= $OCT2 < $OCT3
}
--source include/assert.inc
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction..
if ($is_windows)
{
--let $assert_cond= $OCT3 <= $OCT4
}
if (!$is_windows)
{
--let $assert_cond= $OCT3 < $OCT4
}
--source include/assert.inc
--let $assert_text= Assert that the OCT of a transaction is higher than the earlier transaction..
if ($is_windows)
{
--let $assert_cond= $OCT4 <= $OCT5
}
if (!$is_windows)
{
--let $assert_cond= $OCT4 < $OCT5
}
--source include/assert.inc
--source include/rpl_end.inc
|