-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathlogical_timestamping.inc
215 lines (162 loc) · 5.35 KB
/
logical_timestamping.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
RESET BINARY LOGS AND GTIDS;
# A first event in a new binlog has commit parent timestamp as zero
# and itself as one.
CREATE TABLE t1 (a int) ENGINE= innodb;
--let $binlog_file= binlog.000001
--let $logical_timestamps= 0 1
--source include/rpl/assert_logical_timestamps.inc
# A next transaction increments either counter
--let $binlog_position= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
INSERT INTO t1 SET a=1;
--let $logical_timestamps= 1 2
--source include/rpl/assert_logical_timestamps.inc
# Transaction's last committed timestamp is computed at its last
# being executed query.
# Due to this two last logged transactions in the following sequence
# must have the same last comitted timestamp.
connect (one,localhost,root,,test);
connect (two,localhost,root,,test);
connect (three,localhost,root,,test);
--let $rpl_connection_name=one
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=1;
--let $rpl_connection_name=two
--source include/connection.inc
# (transaction timestamp,last committed) (2,3)
BEGIN;
INSERT INTO t1 SET a=2;
COMMIT;
--let $rpl_connection_name=one
--source include/connection.inc
INSERT INTO t1 SET a=1;
--let $rpl_connection_name=two
--source include/connection.inc
--let $binlog_position= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
# (3,4)
BEGIN;
INSERT INTO t1 SET a=2;
COMMIT;
--let $logical_timestamps= 3 4
--source include/rpl/assert_logical_timestamps.inc
--let $rpl_connection_name=one
--source include/connection.inc
# (3,5)
--let $binlog_position= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
COMMIT;
--let $logical_timestamps= 3 5
--source include/rpl/assert_logical_timestamps.inc
# Two independent and concurrent (autoincrement) transaction will either
# have the same commit parent as the last committed of so far, or
# one of them will be such to another.
--let $binlog_position= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
--let $rpl_connection_name=one
--source include/connection.inc
--send INSERT INTO t1 SET a=1
--let $rpl_connection_name=two
--source include/connection.inc
--send INSERT INTO t1 SET a=2
--let $rpl_connection_name=one
--source include/connection.inc
--reap
--let $rpl_connection_name=two
--source include/connection.inc
--reap
--let $logical_timestamps= 5 6;[56] 7
--source include/rpl/assert_logical_timestamps.inc
#
# Testing logging of transaction that commits after binlog rotation.
# The last committed of "rotated" transaction
# must be set to the uninitialized (0) value.
#
--let $rpl_connection_name=one
--source include/connection.inc
RESET BINARY LOGS AND GTIDS;
INSERT INTO t1 SET a=1;
--let $rpl_connection_name=two
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=2;
--let $rpl_connection_name=one
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=3;
--let $rpl_connection_name=two
--source include/connection.inc
COMMIT;
# Not "rotated" 2nd transaction is logged following the regular rule.
# Its timestamp pair of (1,2) must be found.
--let $binlog_position=
--let $logical_timestamps= 0 1;1 2
--source include/rpl/assert_logical_timestamps.inc
FLUSH LOGS;
--let $rpl_connection_name=one
--source include/connection.inc
COMMIT;
# Now the proof: the "rotated" transaction is logged with uninitialized last committed
# as expected. Its timestamp pair of (0,1) must be found.
--let $binlog_file= binlog.000002
--let $logical_timestamps= 0 1
--source include/rpl/assert_logical_timestamps.inc
#
# Testing logging of transaction that commits after RESET BINARY LOGS AND GTIDS.
# The last committed of "rotated" transactions
# must be set to the uninitialized (0) value.
#
--let $rpl_connection_name=one
--source include/connection.inc
RESET BINARY LOGS AND GTIDS;
INSERT INTO t1 SET a=1;
--let $rpl_connection_name=two
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=2;
--let $rpl_connection_name=one
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=3;
--let $rpl_connection_name=three
--source include/connection.inc
BEGIN;
INSERT INTO t1 SET a=4;
--let $rpl_connection_name=two
--source include/connection.inc
COMMIT;
# Not "rotated" 2nd transaction is logged following the regular rule.
# Its timestamp pair of (1,2) must be found.
--let $binlog_file= binlog.000001
--let $logical_timestamps= 0 1;1 2
--source include/rpl/assert_logical_timestamps.inc
RESET BINARY LOGS AND GTIDS;
--let $rpl_connection_name=one
--source include/connection.inc
COMMIT;
--let $rpl_connection_name=three
--source include/connection.inc
COMMIT;
# Now the proof: the "rotated" transactions are logged with uninitialized last committed
# as expected. Its timestamp pair of (0,[12]) must be found.
--let $logical_timestamps= 0 1;0 2
--source include/rpl/assert_logical_timestamps.inc
#
# Cleanup
#
DROP TABLE t1;
#
# Testing DROP of multiple tables logging
#
CREATE TABLE t1 (a int) ENGINE= innodb;
CREATE TABLE tm (a int) ENGINE= MyISAM;
RESET BINARY LOGS AND GTIDS;
CREATE TEMPORARY TABLE ttm1 (a INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE tti1 (a INT) ENGINE=Innodb;
--echo *** The query is logged in four part.
DROP TABLE tm,t1,ttm1,tti1;
--let $logical_timestamps= 0 1;1 2;2 3;3 4;4 5;5 6
# CREATE/DROP TEMPORARY TABLE is not binlogged under MIXED
--let $logical_timestamps_mix= 0 1;1 2
--source include/rpl/assert_logical_timestamps.inc
#
# The final grep invocation should be done by the top level part.
# It may produce results sensitive to the test environment (e.g GTID).
#