~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/t/backup_snapshot.test

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# This test is for the consistent snapshot online backup driver
 
2
# This test is for the consistent snapshot online backup driver.
3
3
# The test is designed to show that a consistent snapshot
4
4
# backup can be taken while data is being inserted and deleted.
5
5
#
6
6
# The test is testing the driver to ensure it is entering a 
7
7
# consistent read state during the backup. There are several
8
 
# breakpoints in the code that can be used. The two most 
9
 
# useful ones are:
 
8
# synchronization points in the code that can be used.
 
9
# The two most useful ones are:
10
10
#
11
 
#   backup_cs_unlock - occurs after consistent read 
 
11
#   after_backup_cs_locked - occurs after consistent read 
12
12
#     transaction has been started and before the open and
13
13
#     lock tables.
14
14
#
15
 
#   backup_cs_reading - occurs after the open and lock
 
15
#   when_backup_cs_reading - occurs after the open and lock
16
16
#     tables during the read tables portion.
17
17
#
18
18
# The following tests test these conditions.
19
19
#
20
 
# Notes
21
 
#   You must use a dedicated connection for getting and releasing locks.
22
 
# Do not issue a get_lock() or release_lock() in the same connection
23
 
# (thread) as code that calls BACKUP_BREAKPOINT(). Using the same connection
24
 
# to get/release locks and run code that issues BACKUP_BREAKPOINTs will result
25
 
# in an assertion using DEBUG_ASSERT(thd->ull == NULL) from debug_sync_point()
26
 
# in item_func.cc.
27
 
#
28
20
 
29
21
--source include/have_innodb.inc
30
 
--source include/have_debug.inc
 
22
--source include/have_debug_sync.inc
31
23
--source include/not_embedded.inc
32
24
 
 
25
#
 
26
# Preparative cleanup.
 
27
#
33
28
--disable_warnings
 
29
SET DEBUG_SYNC= 'reset';
34
30
DROP DATABASE IF EXISTS bup_snapshot;
35
31
--error 0,1
36
32
--remove_file $MYSQLTEST_VARDIR/master-data/bup_snapshot.bak;
37
33
--enable_warnings
38
34
 
39
 
CREATE DATABASE bup_snapshot;
 
35
--echo #
 
36
--echo # Setup for tests.
 
37
--echo #
40
38
 
41
39
connect (con1,localhost,root,,);
42
40
connect (con2,localhost,root,,);
43
 
connect (con3,localhost,root,,);
44
41
 
45
42
connection con1;
46
43
 
47
 
# Setup the server to use the backup breakpoints
48
 
SET GLOBAL debug="d,backup_debug:d,backup";
49
 
 
50
 
#
51
 
# Setup for tests.
52
 
#
 
44
CREATE DATABASE bup_snapshot;
53
45
 
54
46
# Create a table and load it with lots of data.
55
47
CREATE TABLE bup_snapshot.t1 (word CHAR(20)) ENGINE=INNODB;
74
66
SELECT COUNT(*) FROM bup_snapshot.t1;
75
67
SELECT COUNT(*) FROM bup_snapshot.t2;
76
68
 
77
 
connection con3;
78
 
 
79
 
#
80
 
# Test 1: Check for consistent read prior to open and lock tables
81
 
#
82
 
 
83
 
--echo con3: Getting lock on driver.
84
 
SELECT get_lock("backup_cs_locked", 100);
85
 
 
 
69
--echo #
 
70
--echo # Test 1: Check for consistent read prior to open and lock tables
 
71
--echo #
86
72
# While a consistent snapshot backup is executed,
87
73
# no external inserts should be visible to the transaction.
88
74
 
89
 
connection con1;
 
75
--echo con1: Activate sync points for the backup statement.
 
76
SET DEBUG_SYNC= 'after_backup_cs_locked SIGNAL locked WAIT_FOR inserting';
90
77
 
91
78
--echo con1: Backing up database. Spawn this and continue...
92
79
send BACKUP DATABASE bup_snapshot TO "bup_snapshot.bak";
93
80
 
94
 
connection con3;
95
 
 
96
 
# Wait for lock to be acquired and execution to reach breakpoint
97
 
--echo con3: Checking locks.
98
 
let $wait_condition = SELECT state = "debug_sync_point: backup_cs_locked"
99
 
                      FROM INFORMATION_SCHEMA.PROCESSLIST
100
 
                      WHERE info LIKE "BACKUP DATABASE %";
101
 
--source include/wait_condition.inc
102
 
 
103
 
# Start an insert now that CS has a transaction 
 
81
connection con2;
 
82
 
 
83
--echo con2: Wait for backup to have locked the transaction.
 
84
SET DEBUG_SYNC= 'now WAIT_FOR locked';
 
85
 
 
86
--echo con2: Start an insert now that CS has a transaction 
104
87
# The commit blocker will block this until the read lock of 
105
88
# the backup is released.
106
89
 
107
 
connection con2;
108
 
 
109
 
send INSERT INTO bup_snapshot.t1 VALUES("- Dave Mathews");
110
 
 
111
 
connection con3;
112
 
 
113
 
# Wait for lock to be acquired and execution to reach breakpoint
114
 
--echo con3: Checking locks.
115
 
let $wait_condition = SELECT count(*) = 1
116
 
                      FROM INFORMATION_SCHEMA.PROCESSLIST
117
 
                      WHERE info LIKE "INSERT INTO bup_snapshot.t1%";
118
 
--source include/wait_condition.inc
119
 
 
120
 
--echo con3: Release lock on driver.
121
 
SELECT release_lock("backup_cs_locked");
122
 
 
123
 
connection con1;
124
 
--replace_column 1 #
125
 
reap;
126
 
 
127
 
connection con2;
128
 
 
129
 
reap;
 
90
--echo con2: Activate sync points for the insert statement.
 
91
SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL inserting';
 
92
 
 
93
# Insert will wait in wait_if_global_read_lock() until backup is done.
 
94
INSERT INTO bup_snapshot.t1 VALUES("- Dave Mathews");
 
95
 
 
96
--echo con2: insert additional rows.
130
97
INSERT INTO bup_snapshot.t1 VALUES("- Yes");
131
98
INSERT INTO bup_snapshot.t1 VALUES("- Jethro Tull");
132
99
DELETE FROM bup_snapshot.t1 WHERE word LIKE '10%';
135
102
SELECT * FROM bup_snapshot.t1 WHERE word LIKE '-%';
136
103
SELECT COUNT(*) FROM bup_snapshot.t1;
137
104
 
138
 
# Now restore the database and then check to make sure the new rows
139
 
# were not backed up.
140
 
 
141
 
connection con1; 
 
105
connection con1;
 
106
 
 
107
--echo con1: retrieve backup result.
 
108
--replace_column 1 #
 
109
reap;
 
110
 
 
111
--echo # Now restore the database and then check to make sure the new rows
 
112
--echo # were not backed up.
142
113
 
143
114
--echo con1: Dropping the database
144
115
DROP TABLE bup_snapshot.t1;
154
125
 
155
126
remove_file $MYSQLTEST_VARDIR/master-data/bup_snapshot.bak;
156
127
 
157
 
#
158
 
# Test 2: Check for consistent read after open and lock tables
159
 
#
160
 
 
161
 
connection con3;
162
 
 
163
 
--echo con3: Getting lock on driver.
164
 
SELECT get_lock("backup_cs_reading", 100);
165
 
 
 
128
--echo #
 
129
--echo # Test 2: Check for consistent read after open and lock tables
 
130
--echo #
166
131
# While a consistent snapshot backup is executed,
167
132
# no external inserts should be visible to the transaction.
168
133
 
169
 
connection con1;
 
134
--echo con1: Activate sync points for the backup statement.
 
135
SET DEBUG_SYNC= 'when_backup_cs_reading SIGNAL reading WAIT_FOR inserting';
170
136
 
171
137
--echo con1: Backing up database. Spawn this and continue...
172
138
send BACKUP DATABASE bup_snapshot TO "bup_snapshot.bak";
173
139
 
174
 
connection con3;
175
 
 
176
 
# Wait for lock to be acquired and execution to reach breakpoint
177
 
--echo con3: Checking locks.
178
 
let $wait_condition = SELECT state = "debug_sync_point: backup_cs_reading"
179
 
                      FROM INFORMATION_SCHEMA.PROCESSLIST
180
 
                      WHERE info LIKE "BACKUP DATABASE%";
181
 
--source include/wait_condition.inc
182
 
 
183
 
# Start an insert now that CS has a transaction 
 
140
connection con2;
 
141
 
 
142
--echo con2: Wait for backup to start reading.
 
143
SET DEBUG_SYNC= 'now WAIT_FOR reading';
 
144
 
 
145
--echo con2: Start an insert now that CS has a transaction 
184
146
# The commit blocker will block this until the read lock of 
185
147
# the backup is released.
186
148
 
187
 
connection con2;
188
 
 
189
 
send INSERT INTO bup_snapshot.t1 VALUES("- Dave Mathews");
190
 
 
191
 
connection con3;
192
 
 
193
 
# Wait for lock to be acquired and execution to reach breakpoint
194
 
--echo con3: Checking locks.
195
 
let $wait_condition = SELECT count(*) = 1
196
 
                      FROM INFORMATION_SCHEMA.PROCESSLIST
197
 
                      WHERE info LIKE "INSERT INTO bup_snapshot.t1%";
198
 
--source include/wait_condition.inc
199
 
 
200
 
--echo con3: Release lock on driver.
201
 
SELECT release_lock("backup_cs_reading");
202
 
 
203
 
connection con2;
204
 
 
205
 
reap;
 
149
--echo con2: Activate sync points for the insert statement.
 
150
SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL inserting';
 
151
 
 
152
# Insert will wait in wait_if_global_read_lock() until backup is done.
 
153
INSERT INTO bup_snapshot.t1 VALUES("- Dave Mathews");
 
154
 
 
155
--echo con2: insert additional rows.
206
156
INSERT INTO bup_snapshot.t1 VALUES("- Yes");
207
157
INSERT INTO bup_snapshot.t1 VALUES("- Jethro Tull");
208
158
DELETE FROM bup_snapshot.t1 WHERE word LIKE '10%';
212
162
SELECT COUNT(*) FROM bup_snapshot.t1;
213
163
 
214
164
connection con1;
 
165
 
 
166
--echo con1: retrieve backup result.
215
167
--replace_column 1 #
216
168
reap;
217
169
 
218
 
# Now restore the database and then check to make sure the new rows
219
 
# were not backed up.
 
170
--echo # Now restore the database and then check to make sure the new rows
 
171
--echo # were not backed up.
220
172
 
221
173
--echo con1: Dropping the database
222
174
DROP TABLE bup_snapshot.t1;
230
182
SELECT COUNT(*) FROM bup_snapshot.t1;
231
183
SELECT COUNT(*) FROM bup_snapshot.t2;
232
184
 
 
185
#
 
186
# Cleanup
 
187
#
 
188
SET DEBUG_SYNC= 'reset';
233
189
DROP DATABASE bup_snapshot;
234
 
 
235
190
remove_file $MYSQLTEST_VARDIR/master-data/bup_snapshot.bak;
236
191