Test case looks good. Patch approved.
Chuck Bell wrote:
> #At file:///C:/source/bzr/mysql-6.0-bug-36749/
>
> 2619 Chuck Bell 2008-06-17
> BUG#36778 Read operation during RESTORE leads to data loss
>
> This bug is related to BUG#36749. The patch for BUG#36749 fixes this problem.
> The problem is
> while the native driver is running, any open of the table alters its status
> thereby leaving
> the table in an incorrect state. In this case, the table is emptied. Locking
> the tables
> before restore (as done in BUG#36749) fixes the problem and forces other
> connections to wait
> until the restore is complete to run.
> modified:
> mysql-test/r/backup_lock_myisam.result
> mysql-test/t/backup_lock_myisam.test
>
> per-file messages:
> mysql-test/r/backup_lock_myisam.result
> New result file.
> mysql-test/t/backup_lock_myisam.test
> Test added to ensure the bug does not repeat
> === modified file 'mysql-test/r/backup_lock_myisam.result'
> --- a/mysql-test/r/backup_lock_myisam.result 2008-06-17 12:40:00 +0000
> +++ b/mysql-test/r/backup_lock_myisam.result 2008-06-17 14:42:06 +0000
> @@ -86,6 +86,55 @@ a
> 11
> 12
> 13
> +SET DEBUG_SYNC= 'RESET';
> +DELETE FROM db2.t2;
> +now start the restore and while the restore is running, fire the trigger
> +activate synchronization points for restore.
> +SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
> +RESTORE FROM 'db1.bak';
> +From breakpoints:
> +Wait for restore to reach its synchronization point.
> +SET DEBUG_SYNC= 'now WAIT_FOR wait_for_restore';
> +breakpoints: Show process list.
> +SELECT id, command, state, info FROM INFORMATION_SCHEMA.PROCESSLIST
> +WHERE info LIKE "RESTORE%";
> +From con2:
> +Now do the select while restore is running.
> +SELECT * FROM db1.t1 limit 10;
> +From breakpoints:
> +breakpoints: Sending finish signal to wake restore.
> +SET DEBUG_SYNC= 'now SIGNAL finish';
> +Reattach to connection 2 and finish.
> +a
> +1
> +2
> +3
> +4
> +5
> +6
> +7
> +8
> +9
> +0
> +Reattach to connection 1 and finish.
> +backup_id
> +#
> +Show the count for t1. It should be the same as before restore.
> +SELECT COUNT(*) FROM db1.t1;
> +COUNT(*)
> +327680
> +SELECT * FROM db1.t2;
> +a
> +1
> +2
> +3
> +4
> +5
> +SELECT * FROM db1.t3;
> +a
> +11
> +12
> +13
> cleanup
> DROP DATABASE db1;
> DROP DATABASE db2;
>
> === modified file 'mysql-test/t/backup_lock_myisam.test'
> --- a/mysql-test/t/backup_lock_myisam.test 2008-06-17 12:40:00 +0000
> +++ b/mysql-test/t/backup_lock_myisam.test 2008-06-17 14:42:06 +0000
> @@ -132,6 +132,55 @@ SELECT * FROM db1.t2;
>
> SELECT * FROM db1.t3;
>
> +SET DEBUG_SYNC= 'RESET';
> +
> +#
> +# BUG#36778 - Data loss during select at time of restore.
> +#
> +
> +DELETE FROM db2.t2;
> +
> +--echo now start the restore and while the restore is running, fire the trigger
> +--echo activate synchronization points for restore.
> +SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
> +--send RESTORE FROM 'db1.bak'
> +
> +--echo From breakpoints:
> +--connection breakpoints
> +--echo Wait for restore to reach its synchronization point.
> +SET DEBUG_SYNC= 'now WAIT_FOR wait_for_restore';
> +
> +--echo breakpoints: Show process list.
> +--replace_column 1 #
> +query_vertical SELECT id, command, state, info FROM INFORMATION_SCHEMA.PROCESSLIST
> +WHERE info LIKE "RESTORE%";
> +
> +--echo From con2:
> +--connection con2
> +--echo Now do the select while restore is running.
> +send SELECT * FROM db1.t1 limit 10;
> +
> +--echo From breakpoints:
> +--connection breakpoints
> +--echo breakpoints: Sending finish signal to wake restore.
> +SET DEBUG_SYNC= 'now SIGNAL finish';
> +
> +--echo Reattach to connection 2 and finish.
> +--connection con2
> +--reap
> +
> +--echo Reattach to connection 1 and finish.
> +--connection con1
> +--replace_column 1 #
> +--reap
> +
> +--echo Show the count for t1. It should be the same as before restore.
> +SELECT COUNT(*) FROM db1.t1;
> +
> +SELECT * FROM db1.t2;
> +
> +SELECT * FROM db1.t3;
> +
> --echo cleanup
> DROP DATABASE db1;
> DROP DATABASE db2;
>
>
--
Jørgen Løland