#At file:///localhome/jl208045/mysql/mysql-6.0-backup-32465/
2727 Jorgen Loland 2008-11-05
Bug#32465 - Backup: Commit blocker does not block tables in default driver
The patch contains a commit blocker test written for the temporary commit blocker
solution of setting Global Read Lock before backup prepare phase (fixed in bug#39602).
modified:
mysql-test/suite/backup/r/backup_commit_blocker.result
mysql-test/suite/backup/t/backup_commit_blocker.test
per-file messages:
mysql-test/suite/backup/r/backup_commit_blocker.result
Result for test of temporary solution of backup commit blocker setting global read
lock before prepare phase.
mysql-test/suite/backup/t/backup_commit_blocker.test
Test temporary solution for backup commit blocker setting global read lock before
prepare phase.
=== modified file 'mysql-test/suite/backup/r/backup_commit_blocker.result'
--- a/mysql-test/suite/backup/r/backup_commit_blocker.result 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_blocker.result 2008-11-05 09:38:45 +0000
@@ -64,7 +64,7 @@ SET DEBUG_SYNC= 'before_backup_unblock_c
WAIT_FOR finish';
con1: Backing up database -- will block with lock
BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
+con3: Wait for BACKUP to reach its synchronization point.
SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
con3: Activate synchronization points for COMMIT.
SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
@@ -179,10 +179,19 @@ Starting Test 2
CREATE DATABASE bup_commit_blocker;
con1: Creating tables
+CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
con1: Loading data
+INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
con1: Show that the new data doesn't exist before backup.
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+1
+2
+3
+4
+5
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -190,14 +199,28 @@ col_a
30
40
50
+con6: Activate synchronization point for DELETE.
+SET DEBUG_SYNC= 'at_delete_end SIGNAL del_at_end WAIT_FOR finish_delete';
+con6: Starting non-trx in progress -- will block with lock
+Assumption (d): non-TRX in progress is included in backup
+DELETE FROM bup_commit_blocker.t4 WHERE col_a <= 2;
+con1: Wait for DELETE to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR del_at_end';
con1: Activate synchronization point for BACKUP.
-SET DEBUG_SYNC= 'before_backup_data_unlock SIGNAL bup_data_unlock
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL finish_delete';
+con1: BACKUP can set commit blocker when delete has finished
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL bup_commit_blocked
WAIT_FOR finish';
-con1: Backing up database -- will block with lock
+con1: Backing up database -- will be blocked by delete
BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_data_unlock';
+con7: Wait for BACKUP to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_blocked';
con7: Show that the statement in progress has executed before backup.
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+3
+4
+5
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -206,19 +229,22 @@ col_a
40
50
con7: Activate synchronization point for UPDATE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL upd_read_lock';
+con7: UPDATE is blocked; completes when commit blocker is released
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL finish';
con7: Starting non-trx about to start
Assumption (e): non-TRX not started is not included in backup
UPDATE bup_commit_blocker.t5 SET col_a = 333 WHERE col_a = 30;
-con5: Wait for UPDATE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR upd_read_lock';
-con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
+con6: Fetch DELETE result
con7: Fetch UPDATE result
con1: Fetch BACKUP result
backup_id
#
con1: Showing data after updates and backup
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+3
+4
+5
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -227,12 +253,18 @@ col_a
40
50
con1: Dropping the database
+DROP TABLE bup_commit_blocker.t4;
DROP TABLE bup_commit_blocker.t5;
con1: Restoring the database
RESTORE FROM "bup_commit_blocker.bak";
backup_id
#
con1: Showing the data (no new data should be here).
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+3
+4
+5
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -243,6 +275,10 @@ col_a
Verifying test 2 results:
+T4 should have the changes after backup - count(*) = 3
+SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 2;
+count(*)
+3
T5 should not have the changes after backup - count(*) = 0
SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a = 333;
count(*)
@@ -258,6 +294,7 @@ con1: Creating tables
CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
con1: Loading data
INSERT INTO bup_commit_blocker.t1 VALUES ("01 Some data to test");
@@ -275,6 +312,7 @@ INSERT INTO bup_commit_blocker.t3 VALUES
INSERT INTO bup_commit_blocker.t3 VALUES ("03 Some data to test");
INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
+INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
con1: Show that the new data doesn't exist before backup.
SELECT * FROM bup_commit_blocker.t1;
@@ -298,6 +336,13 @@ col_a
03 Some data to test
04 Some data to test
05 Some data to test
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+1
+2
+3
+4
+5
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -315,39 +360,46 @@ BEGIN;
INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 04 Some data to test");
INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 05 Some data to test");
con1: Activate synchronization points for BACKUP.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
- WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
- WAIT_FOR finish';
+SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_started WAIT_FOR bup_take_lock';
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_wait_read_lock';
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL bup_commit_blocked
+ WAIT_FOR bup_unblock_commit';
con1: Backing up database -- will block with lock
BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
+con6: Activate synchronization point for INSERT.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_started';
+SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_started
+ WAIT_FOR finish_insert';
+con6: Starting non-trx in progress -- blocks backup until signal finish_insert
+Assumption (d): non-TRX in progress is included in backup
+INSERT INTO bup_commit_blocker.t4 VALUES (31), (32), (33);
+con3: Wait for INSERT to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR insert_started';
con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
- WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
+SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL bup_take_lock
+ WAIT_FOR bup_wait_read_lock';
+SET DEBUG_SYNC= 'after_commit SIGNAL finish_insert WAIT_FOR begin_started';
con3: Starting commit -- will block on sync point
COMMIT;
-con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-con5: Let COMMIT continue until the sync point at its end.
-con5: The completed COMMIT implicitly wakes BACKUP.
-con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
+con4: Wait for BACKUP to set commit blocker
+SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_blocked';
con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
- WAIT_FOR finish';
+SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_started';
con4: Starting begin -- will block with lock
Assumption (c): TRX not started is not included in backup
BEGIN;
-con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
con7: Show that the statement in progress has executed before backup.
+SET DEBUG_SYNC= 'now WAIT_FOR begin_started';
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+1
+2
+3
+4
+5
+31
+32
+33
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -356,14 +408,10 @@ col_a
40
50
con7: Activate synchronization point for DELETE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL del_read_lock';
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL bup_unblock_commit';
con7: Starting non-trx about to start -- will block with lock
Assumption (e): non-TRX not started is not included in backup
DELETE FROM bup_commit_blocker.t5 WHERE col_a = 50;
-con5: Wait for DELETE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR del_read_lock';
-con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
con2: Completing transaction
DELETE FROM bup_commit_blocker.t2 WHERE col_a LIKE '02%';
COMMIT;
@@ -372,6 +420,7 @@ con4: Fetch BEGIN result and completing
UPDATE bup_commit_blocker.t3 SET col_a = "con4: 05 CHANGED" WHERE col_a LIKE '05%';
UPDATE bup_commit_blocker.t3 SET col_a = "con4: 06 CHANGED" WHERE col_a LIKE '06%';
COMMIT;
+con6: Fetch INSERT result
con7: Fetch DELETE result
con1: Fetch BACKUP result
backup_id
@@ -399,6 +448,16 @@ col_a
03 Some data to test
04 Some data to test
con4: 05 CHANGED
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+1
+2
+3
+4
+5
+31
+32
+33
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -409,6 +468,7 @@ con1: Dropping the database
DROP TABLE bup_commit_blocker.t1;
DROP TABLE bup_commit_blocker.t2;
DROP TABLE bup_commit_blocker.t3;
+DROP TABLE bup_commit_blocker.t4;
DROP TABLE bup_commit_blocker.t5;
con1: Restoring the database
RESTORE FROM "bup_commit_blocker.bak";
@@ -438,6 +498,16 @@ col_a
03 Some data to test
04 Some data to test
05 Some data to test
+SELECT * FROM bup_commit_blocker.t4;
+col_a
+1
+2
+3
+4
+5
+31
+32
+33
SELECT * FROM bup_commit_blocker.t5;
col_a
10
@@ -460,6 +530,10 @@ T3 should not have the changes after bac
SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
count(*)
0
+T4 should have the changes after backup - count(*) = 3
+SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 30;
+count(*)
+3
T5 should not have the changes after backup - count(*) = 1
SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a >= 50;
count(*)
=== modified file 'mysql-test/suite/backup/t/backup_commit_blocker.test'
--- a/mysql-test/suite/backup/t/backup_commit_blocker.test 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_blocker.test 2008-11-05 09:38:45 +0000
@@ -61,15 +61,6 @@ connect (con5,localhost,root,,);
connect (con6,localhost,root,,);
connect (con7,localhost,root,,);
-#
-# Note: Originally we used SELECT ... FROM INFORMATION_SCHEMA.PROCESSLIST; to show status
of
-# the various connections participating in the test. But INFORMATION_SCHEMA.PROCESSLIST
implementation
-# proved to be not relaiable. From time to time (nondeterminisrtically) test hanged on
these SELECTs.
-# As showing the status is not essential for the test (we test correctness by checking
the contents of
-# the created backup image), the selects are commented out now. They can be re-enabled
when
-# I_S.PROCESSLIST is in a better shape.
-#
-
connection con1;
#
@@ -187,16 +178,10 @@ SET DEBUG_SYNC= 'before_backup_unblock_c
--echo con1: Backing up database -- will block with lock
send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-connection con5;
-
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
connection con3;
+--echo con3: Wait for BACKUP to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
--echo con3: Activate synchronization points for COMMIT.
SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
WAIT_FOR commit_go_done';
@@ -208,26 +193,13 @@ connection con5;
--echo con5: Wait for COMMIT to reach its synchronization point.
SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-
--echo con5: Let BACKUP run until the next sync point.
SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
--echo con5: Let COMMIT continue until end of statement.
--echo con5: The completed COMMIT implicitly wakes BACKUP.
--echo con5: So wait for BACKUP to reach the next synchronization point.
SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
connection con4;
@@ -242,10 +214,6 @@ connection con5;
--echo con5: Wait for BEGIN to reach its synchronization point.
SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BEGIN%";
-
--echo con5: Sending finish signal to wake them all.
SET DEBUG_SYNC= 'now SIGNAL finish';
@@ -326,29 +294,19 @@ SET DEBUG_SYNC= 'RESET';
--echo Starting Test 2
--echo
-# Ingo: DELETE was disabled before converting the test from
-# BACKUP_BREAKPOINT to DEBUG_SYNC. I left it disabled
-# as an attempt to enable it made an infinite loop in
-# write_table_data() in the loop:
-# while (sch.prepare_count > 0)
-# if (sch.step())
-# goto error;
-# sch.prepare_count did not change from being 1.
-# When this is fixed, please remove this comment.
-
#
# Test 2 sequence diagram (not UML)
#
# con1 con2 con3 con4 con5 con6 con7
# (setup) | | | | | |
# | | | | | | |
-# | | | | | #DELETE t4 |
-# | | | | #show status | |
+# | | | | | DELETE t4 |
+# | | | | | | |
# BACKUP | | | | | |
-# | | | | show status | |
+# | | | | | | |
# | | | | | | (results)
# | | | | | | UPDATE t5
-# | | | | show status | |
+# | | | | | | |
# <...> | | | | <...> <...>
# (results) | | | | | |
#
@@ -360,78 +318,59 @@ CREATE DATABASE bup_commit_blocker;
# Create a non-transaction table and load it with data.
--echo con1: Creating tables
-#CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
+CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
--echo con1: Loading data
-#INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
+INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
--echo con1: Show that the new data doesn't exist before backup.
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
-#connection con6;
-#
-#--echo con6: Activate synchronization point for DELETE.
-#SET DEBUG_SYNC= 'at_delete_end SIGNAL del_at_end WAIT_FOR finish';
-#--echo con6: Starting non-trx in progress -- will block with lock
-#--echo Assumption (d): non-TRX in progress is included in backup
-#send DELETE FROM bup_commit_blocker.t4 WHERE col_a <= 2;
-#
-#connection con5;
-#
-#--echo con5: Wait for DELETE to reach its synchronization point.
-#SET DEBUG_SYNC= 'now WAIT_FOR del_at_end';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "DELETE%";
+connection con6;
+
+--echo con6: Activate synchronization point for DELETE.
+SET DEBUG_SYNC= 'at_delete_end SIGNAL del_at_end WAIT_FOR finish_delete';
+--echo con6: Starting non-trx in progress -- will block with lock
+--echo Assumption (d): non-TRX in progress is included in backup
+send DELETE FROM bup_commit_blocker.t4 WHERE col_a <= 2;
connection con1;
+--echo con1: Wait for DELETE to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR del_at_end';
+
--echo con1: Activate synchronization point for BACKUP.
-SET DEBUG_SYNC= 'before_backup_data_unlock SIGNAL bup_data_unlock
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL finish_delete';
+--echo con1: BACKUP can set commit blocker when delete has finished
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL bup_commit_blocked
WAIT_FOR finish';
---echo con1: Backing up database -- will block with lock
+--echo con1: Backing up database -- will be blocked by delete
send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-connection con5;
-
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_data_unlock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
connection con7;
+--echo con7: Wait for BACKUP to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_blocked';
--echo con7: Show that the statement in progress has executed before backup.
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo con7: Activate synchronization point for UPDATE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL upd_read_lock';
+--echo con7: UPDATE is blocked; completes when commit blocker is released
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL finish';
--echo con7: Starting non-trx about to start
--echo Assumption (e): non-TRX not started is not included in backup
send UPDATE bup_commit_blocker.t5 SET col_a = 333 WHERE col_a = 30;
-connection con5;
-
---echo con5: Wait for UPDATE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR upd_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "UPDATE%";
-
---echo con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-
# Reconnect to con6 and con7 and fetch their results.
-#connection con6;
-#
-#--echo con6: Fetch DELETE result
-#reap;
+connection con6;
+
+--echo con6: Fetch DELETE result
+reap;
connection con7;
@@ -449,11 +388,11 @@ reap;
# Do selects to show that all changes got applied.
--echo con1: Showing data after updates and backup
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo con1: Dropping the database
-#DROP TABLE bup_commit_blocker.t4;
+DROP TABLE bup_commit_blocker.t4;
DROP TABLE bup_commit_blocker.t5;
--echo con1: Restoring the database
@@ -461,15 +400,15 @@ DROP TABLE bup_commit_blocker.t5;
RESTORE FROM "bup_commit_blocker.bak";
--echo con1: Showing the data (no new data should be here).
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo
--echo Verifying test 2 results:
--echo
-#--echo T4 should have the changes after backup - count(*) = 3
-#SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 2;
+--echo T4 should have the changes after backup - count(*) = 3
+SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 2;
--echo T5 should not have the changes after backup - count(*) = 0
SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a = 333;
@@ -500,15 +439,15 @@ SET DEBUG_SYNC= 'RESET';
# | | INSERT t2 | | | |
# | | INSERT t2 | | | |
# BACKUP | | | | | |
-# | | | | | #INSERT t4 |
-# | | | | show status | |
+# | | | | | INSERT t4 |
+# | | | | | | |
# | | COMMIT | | | |
-# | | | | show status | |
+# | | | | | | |
# | | | BEGIN | | |
-# | | | | show status | |
+# | | | | | | |
# | | | | | | (results)
# | | | | | | DELETE t5
-# | | | | show status | |
+# | | | | | | |
# | | | | wake all | |
# | DELETE t1 | | | | |
# | COMMIT | | | | |
@@ -530,7 +469,7 @@ CREATE DATABASE bup_commit_blocker;
CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
-#CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
+CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
--echo con1: Loading data
@@ -552,14 +491,14 @@ INSERT INTO bup_commit_blocker.t3 VALUES
INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
-#INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
+INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
--echo con1: Show that the new data doesn't exist before backup.
SELECT * FROM bup_commit_blocker.t1;
SELECT * FROM bup_commit_blocker.t2;
SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
connection con2;
@@ -579,134 +518,72 @@ BEGIN;
connection con1;
-#
-# We must start the backup and allow it to gather the metadata first.
-# We stop (with a sync point) the backup after the metadata but before
-# the commit blocker.
-#
+# Let BACKUP gather metadata, but stop before it sets the commit
+# blocker. con6 INSERT is started and con3 COMMITTED before BACKUP is
+# continued by signaling 'bup_take_lock'. The BACKUP commit blocker
+# should now be blocked by the INSERT. The INSERT is then completed,
+# and BACKUP allowed to set the commit blocker. BACKUP signals
+# 'bup_commit_blocked' when commit blocker has been set, and it is
+# then verified that other DMLs are blocked while the commit blocker
+# is held. When other DML has been verified to be blocked, signal
+# 'bup_unblock_commit' lets BACKUP complete. It is then verified that
+# only non-transactional DMLs and transactions committed prior to the
+# commit blocker was set are restored.
+
--echo con1: Activate synchronization points for BACKUP.
-# Before blocking commits, pause to show processlist state.
-# Before going to wait for the protection against global read lock to
-# disappear, signal about the wait, so that another thread can continue.
-# When COMMIT finishes, it releases the protection against global read lock,
-# which would allow BACKUP to continue while COMMIT also continues and
-# signals "commit_done". It is important that BACKUP does not run in
-# parallel and send another signal without waiting for the commit_done
-# signal to be processed. So BACKUP itself has to wait for that signal
-# after awaking and taking the global read lock. Only then BACKUP
-# can proceed and send a signal telling that it took the global read
-# lock. Unfortunately DEBUG_SYNC does not allow a sync point to emit a
-# signal after a wait_for action. So we need to send the signal in a later
-# sync point. For this test it is not important where this signal is sent,
-# as long as it is sent while BACKUP holds the global read lock.
-# Here we do it "before_backup_unblock_commit", where we have to
-# synchronize anyway.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
- WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
- WAIT_FOR finish';
+SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_started WAIT_FOR bup_take_lock';
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_wait_read_lock';
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL bup_commit_blocked
+ WAIT_FOR bup_unblock_commit';
--echo con1: Backing up database -- will block with lock
send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-#connection con6;
-#
-#--echo con6: Activate synchronization point for INSERT.
-#SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_table_locked
-# WAIT_FOR finish';
-#--echo con6: Starting non-trx in progress -- will block
-#--echo Assumption (d): non-TRX in progress is included in backup
-#send INSERT INTO bup_commit_blocker.t4 VALUES (31), (32), (33);
-
-connection con5;
+connection con6;
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-#--echo con5: Wait for INSERT to reach its synchronization point.
-#SET DEBUG_SYNC= 'now WAIT_FOR insert_table_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
+--echo con6: Activate synchronization point for INSERT.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_started';
+SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_started
+ WAIT_FOR finish_insert';
+--echo con6: Starting non-trx in progress -- blocks backup until signal finish_insert
+--echo Assumption (d): non-TRX in progress is included in backup
+send INSERT INTO bup_commit_blocker.t4 VALUES (31), (32), (33);
connection con3;
+--echo con3: Wait for INSERT to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR insert_started';
--echo con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
- WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
+SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL bup_take_lock
+ WAIT_FOR bup_wait_read_lock';
+SET DEBUG_SYNC= 'after_commit SIGNAL finish_insert WAIT_FOR begin_started';
--echo con3: Starting commit -- will block on sync point
send COMMIT;
-connection con5;
-
---echo con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-
---echo con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
---echo con5: Let COMMIT continue until the sync point at its end.
---echo con5: The completed COMMIT implicitly wakes BACKUP.
---echo con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
+#below this point happens after commit blocker has been set
connection con4;
+--echo con4: Wait for BACKUP to set commit blocker
+SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_blocked';
--echo con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
- WAIT_FOR finish';
+SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_started';
--echo con4: Starting begin -- will block with lock
--echo Assumption (c): TRX not started is not included in backup
send BEGIN;
-connection con5;
-
---echo con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BEGIN%";
-
connection con7;
--echo con7: Show that the statement in progress has executed before backup.
-#SELECT * FROM bup_commit_blocker.t4;
+SET DEBUG_SYNC= 'now WAIT_FOR begin_started';
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo con7: Activate synchronization point for DELETE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL del_read_lock';
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL bup_unblock_commit';
--echo con7: Starting non-trx about to start -- will block with lock
--echo Assumption (e): non-TRX not started is not included in backup
send DELETE FROM bup_commit_blocker.t5 WHERE col_a = 50;
-connection con5;
-
---echo con5: Wait for DELETE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR del_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "DELETE%";
-
---echo con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-
# Reconnect to con2, con3, con4, con6, and con7 and fetch their results.
connection con2;
@@ -730,8 +607,8 @@ COMMIT;
connection con6;
-#--echo con6: Fetch INSERT result
-#reap;
+--echo con6: Fetch INSERT result
+reap;
connection con7;
@@ -752,14 +629,14 @@ reap;
SELECT * FROM bup_commit_blocker.t1;
SELECT * FROM bup_commit_blocker.t2;
SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo con1: Dropping the database
DROP TABLE bup_commit_blocker.t1;
DROP TABLE bup_commit_blocker.t2;
DROP TABLE bup_commit_blocker.t3;
-#DROP TABLE bup_commit_blocker.t4;
+DROP TABLE bup_commit_blocker.t4;
DROP TABLE bup_commit_blocker.t5;
--echo con1: Restoring the database
@@ -770,7 +647,7 @@ RESTORE FROM "bup_commit_blocker.bak";
SELECT * FROM bup_commit_blocker.t1;
SELECT * FROM bup_commit_blocker.t2;
SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
+SELECT * FROM bup_commit_blocker.t4;
SELECT * FROM bup_commit_blocker.t5;
--echo
@@ -786,8 +663,8 @@ SELECT count(*) FROM bup_commit_blocker.
--echo T3 should not have the changes after backup - count(*) = 0
SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
-#--echo T4 should have the changes after backup - count(*) = 3
-#SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 30;
+--echo T4 should have the changes after backup - count(*) = 3
+SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 30;
--echo T5 should not have the changes after backup - count(*) = 1
SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a >= 50;