-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathreplication_timestamps.inc
116 lines (103 loc) · 3.95 KB
/
replication_timestamps.inc
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
# The test file is invoked from rpl.rpl_multi_source_timestamps.test
# and group_replication.gr_replication_timestamps
#
# This file has two main sections:
# 1) Retrieve the OCT and ICT from each server
# 2) Verify that the timestamps are correct
#
# param $gtid - the gtid of the transaction to be checked
# param $master - the master server.
# param $slave - the slave server.
# param $check_master_OCT - if 1, then the test checks if the OCT == ICT in the
# master. Not applicable when a transaction was
# originated by a group member.
# if 0, the test asserts that the OCT and ICT were
# correctly generated by the group member.
# param $check_master_slave_ICT - if 1, then the test checks if the ICT
# increases from master to slave. Not applicable
# between group members.
# if 0, the test asserts that the group member
# replicating the transaction correctly
# generated the ICT.
--echo # 1. Save both timestamps (original/immediate) on all servers.
# Switch to master, save both OCT and ICT.
--let $rpl_connection_name= $master
--source include/connection.inc
--source include/rpl/get_original_commit_timestamp.inc
--let $master_OCT= $original_commit_timestamp
--source include/rpl/get_immediate_commit_timestamp.inc
--let $master_ICT= $immediate_commit_timestamp
# Switch to slave, save both OCT and ICT.
--let $rpl_connection_name= $slave
--source include/connection.inc
--source include/rpl/get_original_commit_timestamp.inc
--let $slave_OCT= $original_commit_timestamp
--source include/rpl/get_immediate_commit_timestamp.inc
--let $slave_ICT= $immediate_commit_timestamp
--echo # 2. Verify that the timestamps are correct.
--let $assert_text= Assert that the OCT is the same on $master and $slave.
--let $assert_cond= $master_OCT = $slave_OCT
--source include/assert.inc
# 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
}
if ($check_master_OCT==1)
{
--let $assert_text= Assert that OCT is the same as ICT on $master
--let $assert_cond= $master_OCT = $master_ICT
--source include/assert.inc
}
if ($check_master_OCT==0)
{
# GR topology, so we check if the OCT and ICT were correctly generated
# In this case, the OCT is not the same as the ICT of the original master, as
# the former is generated before transaction certification.
--let $assert_text= Assert that OCT is smaller than ICT on $master
if ($is_windows)
{
# Due to windows lower resolution timestamps, it may happen that master_OCT
# is equal to master_ICT
--let $assert_cond= $master_OCT <= $master_ICT
}
if (!$is_windows)
{
--let $assert_cond= $master_OCT < $master_ICT
}
--source include/assert.inc
}
# This test is not applicable in a GR topology, so it can be skipped in that case
if ($check_master_slave_ICT==1)
{
--let $assert_text= Assert that ICT increases from $master to $slave
if ($is_windows)
{
# Due to windows lower resolution timestamps, it may happen that master_ICT
# is equal to slave_ICT
--let $assert_cond= $slave_ICT >= $master_ICT
}
if (!$is_windows)
{
--let $assert_cond= $slave_ICT > $master_ICT
}
--source include/assert.inc
}
if ($check_master_slave_ICT==0)
{
# GR topology, so we check if the ICT was correctly generated for a member
# replicating the transaction
--let $assert_text= Assert that OCT is smaller than ICT on $slave
if ($is_windows)
{
# Due to windows lower resolution timestamps, it may happen that slave_OCT
# is equal to slave_ICT
--let $assert_cond= $slave_OCT <= $slave_ICT
}
if (!$is_windows)
{
--let $assert_cond= $slave_OCT < $slave_ICT
}
--source include/assert.inc
}