MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:April 29 2009 12:28pm
Subject:bzr commit into mysql-6.0-backup branch (jorgen.loland:2699) Bug#37303
Bug#42359
View as plain text  
#At file:///localhome/jl208045/mysql/mysql-6.0-backup-42359/ based on revid:ingo.struewing@stripped

 2699 Jorgen Loland	2009-04-29
      Bug#42359 - Restore fails if uncommitted data from falcon table is included in backup image.
      Bug#37303 - Transactions opened before restore see empty InnoDB tables after restore.
                        
      The bugs were fixed by BUG#989. This commit contains a test case only.
     @ mysql-test/suite/backup/r/backup_lock_conflict.result
        Test that RESTORE is blocked by a concurrent transaction operating on a database being restored and that the ongoing transaction is not blocked by restore.
     @ mysql-test/suite/backup/t/backup_lock_conflict.test
        Test that RESTORE is blocked by a concurrent transaction operating on a database being restored and that the ongoing transaction is not blocked by restore.

    added:
      mysql-test/suite/backup/r/backup_lock_conflict.result
      mysql-test/suite/backup/t/backup_lock_conflict.test
=== added file 'mysql-test/suite/backup/r/backup_lock_conflict.result'
--- a/mysql-test/suite/backup/r/backup_lock_conflict.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_lock_conflict.result	2009-04-29 12:28:04 +0000
@@ -0,0 +1,77 @@
+#
+# Test 1: Test that RESTORE ... OVERWRITE is blocked if a
+# concurrent transaction has acquired a lock in a database 
+# being restored
+#
+# 
+# Connection 1: Initialize
+# 
+CREATE DATABASE lock_conflict;
+USE lock_conflict;
+CREATE TABLE tbl1(id INT) ENGINE=FALCON;
+INSERT INTO tbl1 VALUES (1),(2),(3),(5),(7);
+# 
+# Connection 1: Start transaction that is not terminated
+# 
+START TRANSACTION;
+INSERT INTO tbl1 VALUES(50),(51);
+# 
+# Connection 2: BACKUP database
+# 
+USE lock_conflict;
+BACKUP DATABASE lock_conflict TO 'bup_lock_conflict.bak';
+backup_id
+#
+# 
+# Connection 2: Attempt RESTORE. Check that it cannot acquire lock
+# 
+SET DEBUG_SYNC= 'mdl_acquire_exclusive_locks_wait SIGNAL restore_blocked';
+RESTORE FROM 'bup_lock_conflict.bak' OVERWRITE;
+# 
+# Connection 1: Wait until RESTORE reports it is blocked
+# 
+SET DEBUG_SYNC= 'now WAIT_FOR restore_blocked';
+#
+# Connection 1: Continue the transaction and see that it is not affected 
+# by the on-going RESTORE operation (BUG#37303).
+#
+INSERT INTO tbl1 VALUES (60), (61);
+SELECT * FROM tbl1;
+id
+1
+2
+3
+5
+7
+50
+51
+60
+61
+#
+# Connection 1: Finish transaction. This removes metadata locks and 
+# allows RESTORE to complete and overwrite the table.
+#
+COMMIT;
+# 
+# Connection 2: Check that RESTORE can complete now that the 
+# concurrent thread has terminated
+# 
+backup_id
+#
+COMMIT;
+# 
+# Connection 2: Exercise objects
+# 
+SELECT * FROM tbl1;
+id
+1
+2
+3
+5
+7
+COMMIT;
+# 
+# Connection 1: Cleanup
+# 
+DROP DATABASE lock_conflict;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup/t/backup_lock_conflict.test'
--- a/mysql-test/suite/backup/t/backup_lock_conflict.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_lock_conflict.test	2009-04-29 12:28:04 +0000
@@ -0,0 +1,95 @@
+#
+# The goal of this test is to verify that RESTORE is correctly blocked
+# by concurrent transactions that operate on a database being restored.
+#
+
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+connect (con1,localhost,root,,); # Concurrent thread - causes locking conflict
+connect (con2,localhost,root,,); # Backup / restore thread
+
+--echo #
+--echo # Test 1: Test that RESTORE ... OVERWRITE is blocked if a
+--echo # concurrent transaction has acquired a lock in a database 
+--echo # being restored
+--echo #
+
+--echo # 
+--echo # Connection 1: Initialize
+--echo # 
+connection con1;
+
+CREATE DATABASE lock_conflict;
+USE lock_conflict;
+
+CREATE TABLE tbl1(id INT) ENGINE=FALCON;
+INSERT INTO tbl1 VALUES (1),(2),(3),(5),(7);
+
+--echo # 
+--echo # Connection 1: Start transaction that is not terminated
+--echo # 
+START TRANSACTION;
+INSERT INTO tbl1 VALUES(50),(51);
+
+  --echo # 
+  --echo # Connection 2: BACKUP database
+  --echo # 
+  connection con2;
+
+  USE lock_conflict;
+  --replace_column 1 #
+  BACKUP DATABASE lock_conflict TO 'bup_lock_conflict.bak';
+
+  --echo # 
+  --echo # Connection 2: Attempt RESTORE. Check that it cannot acquire lock
+  --echo # 
+  SET DEBUG_SYNC= 'mdl_acquire_exclusive_locks_wait SIGNAL restore_blocked';
+  send RESTORE FROM 'bup_lock_conflict.bak' OVERWRITE;
+
+--echo # 
+--echo # Connection 1: Wait until RESTORE reports it is blocked
+--echo # 
+connection con1;
+SET DEBUG_SYNC= 'now WAIT_FOR restore_blocked';
+
+--echo #
+--echo # Connection 1: Continue the transaction and see that it is not affected 
+--echo # by the on-going RESTORE operation (BUG#37303).
+--echo #
+INSERT INTO tbl1 VALUES (60), (61);
+SELECT * FROM tbl1;
+
+--echo #
+--echo # Connection 1: Finish transaction. This removes metadata locks and 
+--echo # allows RESTORE to complete and overwrite the table.
+--echo #
+COMMIT;
+
+  --echo # 
+  --echo # Connection 2: Check that RESTORE can complete now that the 
+  --echo # concurrent thread has terminated
+  --echo # 
+  connection con2;
+  --replace_column 1 #
+  reap;
+  COMMIT;
+
+  --echo # 
+  --echo # Connection 2: Exercise objects
+  --echo # 
+  SELECT * FROM tbl1;
+  COMMIT;
+
+--echo # 
+--echo # Connection 1: Cleanup
+--echo # 
+connection con1;
+DROP DATABASE lock_conflict;
+
+let $BACKUPDIR=`select @@backupdir`;
+--remove_file $BACKUPDIR/bup_lock_conflict.bak
+
+SET DEBUG_SYNC= 'RESET';
+
+


Attachment: [text/bzr-bundle] bzr/jorgen.loland@sun.com-20090429122804-644hzpogk93scuro.bundle
Thread
bzr commit into mysql-6.0-backup branch (jorgen.loland:2699) Bug#37303Bug#42359Jorgen Loland29 Apr