File: rpl_system_versioning_partitions.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (249 lines) | stat: -rw-r--r-- 8,462 bytes parent folder | download | duplicates (2)
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#
#   Ensure that executing row-injected events (i.e. via BINLOG statments and
# row-based binlog events) uses historical partitions. That is, for tables
# which use system versioning and system_time partitions, MDEV-35096 reported
# that row-injected events would not be stored into the correct historical
# partition. This test considers both use cases of row-injected events.
#
#   The test setup creates a system-versioned table with system_time-based
# partitioning and fills the table up with enough records that bypass the size
# limit of each historical partition.
#
#   To test BINLOG statements, a series of BINLOG statements are used to delete
# all the records in the test tables, and the resulting partitions are analyzed
# to ensure that they match the partition specification.  The BINLOG events
# were collected by running an original set of delete statements on the table
# data, and taking their binlog data from mysqlbinlog. Note these binary log
# events are actually Update events, because system versioning just archives
# the rows, rather than deleting them.
#
#   To test row-based event replication, a slave replicates the master's
# events, and the partitions are compared between the slave and master for
# consistency.
#
# Note that the TIMESTAMP of this test is fixed so the BINLOG statements can
# identify the correct rows to delete (system versioning adds implicit fields
# `row_start` and `row_end`, which are automatically populated using the current
# timestamp).
#
#
# References:
#   MDEV-35096: History is stored in different partitions on different nodes
#               when using SYSTEM VERSION
#
--source include/have_64bit_timestamp.inc
--source include/have_binlog_format_row.inc
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/master-slave.inc

--echo #
--echo # Initialize system-versioned and partitioned table and its data
--connection master

# Fix the timestamp for the system versioned row_start and row_end fields, so
# the later hard-coded BINLOG base64 data can find the rows.
SET timestamp=UNIX_TIMESTAMP('2025-01-01 01:00:00.000000');
RESET MASTER;

create table t1 (x int) engine=InnoDB with system versioning partition by system_time limit 3 partitions 5;
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
insert into t1 values(5);
--let $master_total_size= `select count(*) from t1`
--let $master_p0_size= `select count(*) from t1 partition (p0)`
--let $master_p1_size= `select count(*) from t1 partition (p1)`
--let $master_p2_size= `select count(*) from t1 partition (p2)`

--echo # Verifying master partitions are correct after data insertion..
if ($master_total_size != 5)
{
  --echo # Master t1 count: $master_total_size
  --die Master table t1 should have 5 entries
}
if ($master_p0_size)
{
  --echo # Master t1,p0 count: $master_p0_size
  --die Master t1 partition p0 should be empty
}
if ($master_p1_size)
{
  --echo # Master t1,p1 count: $master_p1_size
  --die Master t1 partition p1 should be empty
}
if ($master_p2_size)
{
  --echo # Master t1,p2 count: $master_p2_size
  --die Master t1 partition p2 should be empty
}
--echo # .. done

--sync_slave_with_master

--connection slave
--let $slave_total_size= `select count(*) from t1`
--let $slave_p0_size= `select count(*) from t1 partition (p0)`
--let $slave_p1_size= `select count(*) from t1 partition (p1)`
--let $slave_p2_size= `select count(*) from t1 partition (p2)`

--echo # Verifying partitions of master and slave match on data setup..
if ($slave_total_size != $master_total_size)
{
  --connection master
  select count(*) from t0;
  --connection slave
  select count(*) from t1;
  --die Size of t1 differs between master and slave
}
if ($slave_p0_size != $master_p0_size)
{
  --connection master
  select count(*) from t1 partition (p0);
  --connection slave
  select count(*) from t1 partition (p0);
  --die Size of t1 partition p0 differs between master and slave
}
if ($slave_p1_size != $master_p1_size)
{
  --connection master
  select count(*) from t1 partition (p1);
  --connection slave
  select count(*) from t1 partition (p1);
  --die Size of t1 partition p1 differs between master and slave
}
if ($slave_p2_size != $master_p2_size)
{
  --connection master
  select count(*) from t1 partition (p2);
  --connection slave
  select count(*) from t1 partition (p2);
  --die Size of t1 partition p2 differs between master and slave
}
--echo # .. done

--echo #
--echo # "Delete" each row -- these are the BINLOG commands generated by
--echo # mysqlbinlog from `delete from t1 where x=<n>` statments. Because the
--echo # table uses system versioning and system_time partition, the actual
--echo # events are updates, with added fields for the `row_start` and `row_end`
--echo # columns.
--connection master

--echo # BINLOG for Format Description event
BINLOG '
APZ0Zw8BAAAA/AAAAAABAAAAAAQAMTEuNy4yLU1hcmlhREItZGVidWctbG9nAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA9nRnEzgNAAgAEgAEBAQEEgAA5AAEGggAAAAICAgCAAAACgoKAAAAAAAA
CgoKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAEEwQADQgICAoKCgGuUmo6
';

--echo # BINLOG for delete from t1 where x=1;
BINLOG '
APZ0ZxMBAAAAMQAAAAAAAAAAACEAAAAAAAEABHRlc3QAAnQxAAMDERECBgYBoCHyJQ==
APZ0ZxgBAAAASAAAAAAAAAAAACEAAAAAAAEAAwcH+AEAAABndPYAAAAA/////w9CP/gBAAAAZ3T2
AAAAAGd09gAAAAAuqwNP
';

--echo # BINLOG for delete from t1 where x=2;
BINLOG '
APZ0ZxMBAAAAMQAAAAAAAAAAACEAAAAAAAEABHRlc3QAAnQxAAMDERECBgYBoCHyJQ==
APZ0ZxgBAAAASAAAAAAAAAAAACEAAAAAAAEAAwcH+AIAAABndPYAAAAA/////w9CP/gCAAAAZ3T2
AAAAAGd09gAAAAAsSeT/
';


--echo # BINLOG for delete from t1 where x=3;
BINLOG '
APZ0ZxMBAAAAMQAAAAAAAAAAACEAAAAAAAEABHRlc3QAAnQxAAMDERECBgYBoCHyJQ==
APZ0ZxgBAAAASAAAAAAAAAAAACEAAAAAAAEAAwcH+AMAAABndPYAAAAA/////w9CP/gDAAAAZ3T2
AAAAAGd09gAAAADS6EaQ
';

--echo # BINLOG for delete from t1 where x=4;
BINLOG '
APZ0ZxMBAAAAMQAAAAAAAAAAACEAAAAAAAEABHRlc3QAAnQxAAMDERECBgYBoCHyJQ==
APZ0ZxgBAAAASAAAAAAAAAAAACEAAAAAAAEAAwcH+AQAAABndPYAAAAA/////w9CP/gEAAAAZ3T2
AAAAAGd09gAAAABpi1pF
';

--echo # BINLOG for delete from t1 where x=5;
BINLOG '
APZ0ZxMBAAAAMQAAAAAAAAAAACEAAAAAAAEABHRlc3QAAnQxAAMDERECBgYBoCHyJQ==
APZ0ZxgBAAAASAAAAAAAAAAAACEAAAAAAAEAAwcH+AUAAABndPYAAAAA/////w9CP/gFAAAAZ3T2
AAAAAGd09gAAAACXKvgq
';

--let $master_total_size= `select count(*) from t1`
--let $master_p0_size= `select count(*) from t1 partition (p0)`
--let $master_p1_size= `select count(*) from t1 partition (p1)`
--let $master_p2_size= `select count(*) from t1 partition (p2)`
--echo # Verifying master partitions are correct after deletion BINLOG stmts..
if ($master_total_size > 0)
{
  --echo # Master t1 count: $master_total_size
  --die Master table t1 should have 0 count
}
if ($master_p0_size != 3)
{
  --echo # Master t1,p0 count: $master_p0_size
  --die Master t1 partition p0 should have 3 entries
}
if ($master_p1_size != 2)
{
  --echo # Master t1,p1 count: $master_p1_size
  --die Master t1 partition p1 should have 2 entries
}
if ($master_p2_size)
{
  --echo # Master t1,p2 count: $master_p2_size
  --die Master t1 partition p2 should be empty
}
--echo # .. done
--sync_slave_with_master

--connection slave
--let $slave_total_size= `select count(*) from t1`
--let $slave_p0_size= `select count(*) from t1 partition (p0)`
--let $slave_p1_size= `select count(*) from t1 partition (p1)`
--let $slave_p2_size= `select count(*) from t1 partition (p2)`

if ($slave_total_size != $master_total_size)
{
  --connection master
  select count(*) from t1;
  --connection slave
  select count(*) from t1;
  --die Size of t1 differs between master and slave
}
if ($slave_p0_size != $master_p0_size)
{
  --connection master
  select count(*) from t1 partition (p0);
  --connection slave
  select count(*) from t1 partition (p0);
  --die Size of t1 partition p0 differs between master and slave
}
if ($slave_p1_size != $master_p1_size)
{
  --connection master
  select count(*) from t1 partition (p1);
  --connection slave
  select count(*) from t1 partition (p1);
  --die Size of t1 partition p1 differs between master and slave
}
if ($slave_p2_size != $master_p2_size)
{
  --connection master
  select count(*) from t1 partition (p2);
  --connection slave
  select count(*) from t1 partition (p2);
  --die Size of t1 partition p2 differs between master and slave
}

--connection master
drop table t1;

--source include/rpl_end.inc