File: rpl_replication_timestamps.inc

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 (116 lines) | stat: -rw-r--r-- 4,041 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
# 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/rpl_connection.inc

--source include/get_original_commit_timestamp.inc
--let $master_OCT= $original_commit_timestamp

--source include/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/rpl_connection.inc

--source include/get_original_commit_timestamp.inc
--let $slave_OCT= $original_commit_timestamp

--source include/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
}