#At file:///home/thava/repo/backup/ based on revid:charles.bell@stripped
2870 Thava Alagu 2009-10-05
Bug#47281: BML may not block all it should
Added check table and analyze table commands to the list of
statements protected by backup meta lock.
modified:
mysql-test/suite/backup/r/backup_bml_not_falcon.result
mysql-test/suite/backup/t/backup_bml_not_falcon.test
sql/sql_parse.cc
=== modified file 'mysql-test/suite/backup/r/backup_bml_not_falcon.result'
--- a/mysql-test/suite/backup/r/backup_bml_not_falcon.result 2009-06-30 07:51:04 +0000
+++ b/mysql-test/suite/backup/r/backup_bml_not_falcon.result 2009-10-05 12:16:00 +0000
@@ -2950,6 +2950,410 @@ SET DEBUG_SYNC= 'reset';
SET DEBUG_SYNC= 'reset';
SET DEBUG_SYNC= 'reset';
SET debug="-d";
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (3),(4);
+
+########################################################
+# Running BML test for the following statements:
+#
+# DDL1= CHECK TABLE t1
+# DDL2= ANALYZE TABLE t2
+# DDL3= TRUNCATE TABLE t1
+# DDL4= TRUNCATE TABLE t2
+#
+# BML is activated by BACKUP DATABASE bml_test TO 'bml_test.bkp'.
+########################################################
+
+SET DEBUG_SYNC= 'reset';
+PURGE BACKUP LOGS;
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+
+== Checkpoint A ==
+# Check the initial situation.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+2
+rows_in_t2
+2
+Table Checksum
+bml_test.t1 2865344526
+bml_test.t2 1578680517
+==================
+
+# con1: Start DDL1 making it to stop after it has started (and
+# possibly registered with BML).
+SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL ddl1_started
+ WAIT_FOR continue_ddl';
+CHECK TABLE t1;
+# con2: Wait for DDL1 to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl1_started TIMEOUT 15';
+# con2: Start DDL2 making it to stop after it has started (and
+# possibly registered with BML).
+SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL ddl2_started
+ WAIT_FOR continue_ddl';
+ANALYZE TABLE t2;
+# con5: Wait for DDL2 to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl2_started TIMEOUT 15';
+SET DEBUG_SYNC='before_execute_sql_command CLEAR';
+# con5: Activate synchronization points for BACKUP/RESTORE.
+SET DEBUG_SYNC= 'bml_get_check2 SIGNAL bup_waiting';
+SET DEBUG_SYNC= 'after_backup_start_backup WAIT_FOR continue_bup';
+SET DEBUG_SYNC= 'after_backup_start_restore WAIT_FOR continue_bup';
+SET DEBUG_SYNC= 'before_backup_meta SIGNAL bup_running WAIT_FOR finish_bup';
+SET DEBUG_SYNC= 'start_do_restore SIGNAL bup_running WAIT_FOR finish_bup';
+# con5: Starting BACKUP/RESTORE operation -- should be blocked
+# by ongoing DDLs.
+SET SESSION debug="+d,set_backup_id";
+BACKUP DATABASE bml_test TO 'bml_test.bkp';
+# Waiting for BACKUP/RESTORE to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_waiting TIMEOUT 15';
+
+== Checkpoint B ==
+#
+# DDL1= CHECK TABLE t1
+# DDL2= ANALYZE TABLE t2
+# DDL3= TRUNCATE TABLE t1
+# DDL4= TRUNCATE TABLE t2
+#
+# Checking that BACKUP is blocked by DDLs.
+SELECT object, notes, error_num FROM mysql.backup_progress WHERE backup_id=500;
+object notes error_num
+backup kernel starting 0
+backup kernel running 0
+# Checking that DDL1 and DDL2 have not executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+2
+rows_in_t2
+2
+Table Checksum
+bml_test.t1 2865344526
+bml_test.t2 1578680517
+==================
+
+# Resume DDL1 and DDL2.
+# Now BACKUP/RESTORE should stop after acquiring BML.
+SET DEBUG_SYNC= 'now SIGNAL continue_ddl';
+# con1: Reaping DDL1
+Table Op Msg_type Msg_text
+bml_test.t1 check status OK
+# con2: Reaping DDL2
+Table Op Msg_type Msg_text
+bml_test.t2 analyze status OK
+SET DEBUG_SYNC= 'now SIGNAL continue_bup WAIT_FOR bup_running TIMEOUT 15';
+
+== Checkpoint C ==
+#
+# DDL1= CHECK TABLE t1
+# DDL2= ANALYZE TABLE t2
+# DDL3= TRUNCATE TABLE t1
+# DDL4= TRUNCATE TABLE t2
+#
+# Checking that DDL1 and DDL2 have executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+2
+rows_in_t2
+2
+Table Checksum
+bml_test.t1 2865344526
+bml_test.t2 1578680517
+==================
+
+# con3: Send DDL3 but it is blocked by BACKUP/RESTORE
+# (will not be in backup) make it send signal when
+# blocked on BML.
+SET DEBUG_SYNC= 'bml_enter_check SIGNAL ddl3_blocked';
+TRUNCATE TABLE t1;
+# Wait for DDL3 to send its signal.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl3_blocked TIMEOUT 15';
+# con3: Send DDL3 but it is blocked by BACKUP/RESTORE
+# (will not be in backup) make it send signal when
+# blocked on BML.
+SET DEBUG_SYNC= 'bml_enter_check SIGNAL ddl4_blocked';
+TRUNCATE TABLE t2;
+# Wait for DDL4 to send its signal.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl4_blocked TIMEOUT 15';
+
+== Checkpoint D ==
+#
+# DDL1= CHECK TABLE t1
+# DDL2= ANALYZE TABLE t2
+# DDL3= TRUNCATE TABLE t1
+# DDL4= TRUNCATE TABLE t2
+#
+# Checking that DDL3 and DDL4 have not executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+2
+rows_in_t2
+2
+Table Checksum
+bml_test.t1 2865344526
+bml_test.t2 1578680517
+==================
+
+# Resume BACKUP/RESTORE - this allows DDL3 and DDL4 to complete.
+SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+# con5: Reaping BACKUP/RESTORE
+backup_id
+500
+# con3: Completing DDL3
+# con4: Completing DDL4
+
+== Checkpoint E ==
+#
+# DDL1= CHECK TABLE t1
+# DDL2= ANALYZE TABLE t2
+# DDL3= TRUNCATE TABLE t1
+# DDL4= TRUNCATE TABLE t2
+#
+# Checking that DDL3 and DDL4 have executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+0
+rows_in_t2
+0
+Table Checksum
+bml_test.t1 0
+bml_test.t2 0
+==================
+
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET debug="-d";
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (3);
+
+########################################################
+# Running BML test for the following statements:
+#
+# DDL1= TRUNCATE t1
+# DDL2= TRUNCATE t2
+# DDL3= CHECK TABLE t1
+# DDL4= ANALYZE TABLE t2
+#
+# BML is activated by RESTORE FROM 'bml_test.bkp' OVERWRITE.
+########################################################
+
+SET DEBUG_SYNC= 'reset';
+PURGE BACKUP LOGS;
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+SET DEBUG_SYNC= 'reset';
+USE bml_test;
+
+== Checkpoint A ==
+# Check the initial situation.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+1
+rows_in_t2
+1
+Table Checksum
+bml_test.t1 3459908756
+bml_test.t2 1681116191
+==================
+
+# con1: Start DDL1 making it to stop after it has started (and
+# possibly registered with BML).
+SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL ddl1_started
+ WAIT_FOR continue_ddl';
+TRUNCATE t1;
+# con2: Wait for DDL1 to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl1_started TIMEOUT 15';
+# con2: Start DDL2 making it to stop after it has started (and
+# possibly registered with BML).
+SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL ddl2_started
+ WAIT_FOR continue_ddl';
+TRUNCATE t2;
+# con5: Wait for DDL2 to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl2_started TIMEOUT 15';
+SET DEBUG_SYNC='before_execute_sql_command CLEAR';
+# con5: Activate synchronization points for BACKUP/RESTORE.
+SET DEBUG_SYNC= 'bml_get_check2 SIGNAL bup_waiting';
+SET DEBUG_SYNC= 'after_backup_start_backup WAIT_FOR continue_bup';
+SET DEBUG_SYNC= 'after_backup_start_restore WAIT_FOR continue_bup';
+SET DEBUG_SYNC= 'before_backup_meta SIGNAL bup_running WAIT_FOR finish_bup';
+SET DEBUG_SYNC= 'start_do_restore SIGNAL bup_running WAIT_FOR finish_bup';
+# con5: Starting BACKUP/RESTORE operation -- should be blocked
+# by ongoing DDLs.
+SET SESSION debug="+d,set_backup_id";
+RESTORE FROM 'bml_test.bkp' OVERWRITE;
+# Waiting for BACKUP/RESTORE to reach its synchronization point.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_waiting TIMEOUT 15';
+
+== Checkpoint B ==
+#
+# DDL1= TRUNCATE t1
+# DDL2= TRUNCATE t2
+# DDL3= CHECK TABLE t1
+# DDL4= ANALYZE TABLE t2
+#
+# Checking that BACKUP is blocked by DDLs.
+SELECT object, notes, error_num FROM mysql.backup_progress WHERE backup_id=500;
+object notes error_num
+backup kernel starting 0
+backup kernel running 0
+# Checking that DDL1 and DDL2 have not executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+1
+rows_in_t2
+1
+Table Checksum
+bml_test.t1 3459908756
+bml_test.t2 1681116191
+==================
+
+# Resume DDL1 and DDL2.
+# Now BACKUP/RESTORE should stop after acquiring BML.
+SET DEBUG_SYNC= 'now SIGNAL continue_ddl';
+# con1: Reaping DDL1
+# con2: Reaping DDL2
+SET DEBUG_SYNC= 'now SIGNAL continue_bup WAIT_FOR bup_running TIMEOUT 15';
+
+== Checkpoint C ==
+#
+# DDL1= TRUNCATE t1
+# DDL2= TRUNCATE t2
+# DDL3= CHECK TABLE t1
+# DDL4= ANALYZE TABLE t2
+#
+# Checking that DDL1 and DDL2 have executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+0
+rows_in_t2
+0
+Table Checksum
+bml_test.t1 0
+bml_test.t2 0
+==================
+
+# con3: Send DDL3 but it is blocked by BACKUP/RESTORE
+# (will not be in backup) make it send signal when
+# blocked on BML.
+SET DEBUG_SYNC= 'bml_enter_check SIGNAL ddl3_blocked';
+CHECK TABLE t1;
+# Wait for DDL3 to send its signal.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl3_blocked TIMEOUT 15';
+# con3: Send DDL3 but it is blocked by BACKUP/RESTORE
+# (will not be in backup) make it send signal when
+# blocked on BML.
+SET DEBUG_SYNC= 'bml_enter_check SIGNAL ddl4_blocked';
+ANALYZE TABLE t2;
+# Wait for DDL4 to send its signal.
+SET DEBUG_SYNC= 'now WAIT_FOR ddl4_blocked TIMEOUT 15';
+
+== Checkpoint D ==
+#
+# DDL1= TRUNCATE t1
+# DDL2= TRUNCATE t2
+# DDL3= CHECK TABLE t1
+# DDL4= ANALYZE TABLE t2
+#
+# Checking that DDL3 and DDL4 have not executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+0
+rows_in_t2
+0
+Table Checksum
+bml_test.t1 0
+bml_test.t2 0
+==================
+
+# Resume BACKUP/RESTORE - this allows DDL3 and DDL4 to complete.
+SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+# con5: Reaping BACKUP/RESTORE
+backup_id
+500
+# con3: Completing DDL3
+Table Op Msg_type Msg_text
+bml_test.t1 check status OK
+# con4: Completing DDL4
+Table Op Msg_type Msg_text
+bml_test.t2 analyze status Table is already up to date
+
+== Checkpoint E ==
+#
+# DDL1= TRUNCATE t1
+# DDL2= TRUNCATE t2
+# DDL3= CHECK TABLE t1
+# DDL4= ANALYZE TABLE t2
+#
+# Checking that DDL3 and DDL4 have executed.
+CALL test.check_results();
+Tables_in_bml_test
+t1
+t2
+rows_in_t1
+2
+rows_in_t2
+2
+Table Checksum
+bml_test.t1 2865344526
+bml_test.t2 1578680517
+==================
+
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET DEBUG_SYNC= 'reset';
+SET debug="-d";
DROP DATABASE bml_test;
DROP PROCEDURE test.check_results;
=== modified file 'mysql-test/suite/backup/t/backup_bml_not_falcon.test'
--- a/mysql-test/suite/backup/t/backup_bml_not_falcon.test 2009-06-30 07:51:04 +0000
+++ b/mysql-test/suite/backup/t/backup_bml_not_falcon.test 2009-10-05 12:16:00 +0000
@@ -471,7 +471,7 @@ END\\
--delimiter ;
#
-# Check with BACKUP
+# Check with BACKUP : Round 1
#
let $DDL1= OPTIMIZE TABLE t1;
let $DDL2= REPAIR TABLE t2 USE_FRM;
@@ -484,7 +484,7 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (3);
#
-# Check with RESTORE
+# Check with RESTORE : Round 1
#
let $DDL1= TRUNCATE t1;
let $DDL2= TRUNCATE t2;
@@ -493,6 +493,39 @@ let $DDL4= OPTIMIZE TABLE t2;
let $restore_from= bml_test.bkp;
--source suite/backup/include/bml_test.inc
+--remove_file $bdir/bml_test.bkp
+
+# Round 2
+
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (3),(4);
+
+#
+# Check with BACKUP : Round 2
+#
+let $DDL1= CHECK TABLE t1;
+let $DDL2= ANALYZE TABLE t2;
+let $DDL3= TRUNCATE TABLE t1;
+let $DDL4= TRUNCATE TABLE t2;
+let $backup_to= bml_test.bkp;
+--source suite/backup/include/bml_test.inc
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (3);
+
+#
+# Check with RESTORE : Round 2
+#
+let $DDL1= TRUNCATE t1;
+let $DDL2= TRUNCATE t2;
+let $DDL3= CHECK TABLE t1;
+let $DDL4= ANALYZE TABLE t2;
+let $restore_from= bml_test.bkp;
+--source suite/backup/include/bml_test.inc
+
#
# Cleanup
#
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2009-09-10 13:46:13 +0000
+++ b/sql/sql_parse.cc 2009-10-05 12:16:00 +0000
@@ -377,6 +377,8 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_REPAIR]|= CF_BLOCKED_BY_BML;
sql_command_flags[SQLCOM_OPTIMIZE]|= CF_BLOCKED_BY_BML;
sql_command_flags[SQLCOM_TRUNCATE]|= CF_BLOCKED_BY_BML;
+ sql_command_flags[SQLCOM_ANALYZE]|= CF_BLOCKED_BY_BML;
+ sql_command_flags[SQLCOM_CHECK]|= CF_BLOCKED_BY_BML;
}
Attachment: [text/bzr-bundle] bzr/thavamuni.alagu@sun.com-20091005121600-e9k5om9ttzjcfdb0.bundle