#At file:///localhome/jl208045/mysql/mysql-6.0-backup-40970/
2737 Jorgen Loland 2008-12-15
Bug#40970 - Errors from commit blocker are not logged.
If block_commits fails, an error is now logged. unblock_commits cannot fail.
modified:
mysql-test/suite/backup/r/backup_errors.result
mysql-test/suite/backup/t/backup_errors.test
sql/backup/data_backup.cc
sql/share/errmsg.txt
per-file messages:
mysql-test/suite/backup/r/backup_errors.result
Add tests for error injection inside block_commits
mysql-test/suite/backup/t/backup_errors.test
Add tests for error injection inside block_commits
sql/backup/data_backup.cc
Log error if block_commits fails and add dbug hooks inside block_commits.
sql/share/errmsg.txt
Added error message for when backup fails to block commits
=== modified file 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/suite/backup/r/backup_errors.result 2008-12-10 15:53:06 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result 2008-12-15 09:22:24 +0000
@@ -218,4 +218,17 @@ Show that inserted value 2 is not there
SELECT * FROM table1;
text
Inserted before
+#
+# Test error handling by backup code when injecting commit blocker error.
+#
+SET SESSION DEBUG='+d,backup_grl_fail';
+BACKUP DATABASE db1 TO 'overwrite1.bak';
+ERROR HY000: Backup failed to synchronize table images.
+SET SESSION DEBUG='-d';
+
+SET SESSION DEBUG='+d,backup_grl_block_commit_fail';
+BACKUP DATABASE db1 TO 'overwrite1.bak';
+ERROR HY000: Backup failed to synchronize table images.
+SET SESSION DEBUG='-d';
+
DROP DATABASE db1;
=== modified file 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/suite/backup/t/backup_errors.test 2008-12-10 15:53:06 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test 2008-12-15 09:22:24 +0000
@@ -377,4 +377,22 @@ RESTORE FROM 'overwrite.bak';
--echo Show that inserted value 2 is not there
SELECT * FROM table1;
+--echo #
+--echo # Test error handling by backup code when injecting commit blocker error.
+--echo #
+
+SET SESSION DEBUG='+d,backup_grl_fail';
+--error ER_BACKUP_SYNCHRONIZE
+BACKUP DATABASE db1 TO 'overwrite1.bak';
+SET SESSION DEBUG='-d';
+
+--echo
+
+SET SESSION DEBUG='+d,backup_grl_block_commit_fail';
+--error ER_BACKUP_SYNCHRONIZE
+BACKUP DATABASE db1 TO 'overwrite1.bak';
+SET SESSION DEBUG='-d';
+
+--echo
+
DROP DATABASE db1;
=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc 2008-11-26 10:05:19 +0000
+++ b/sql/backup/data_backup.cc 2008-12-15 09:22:24 +0000
@@ -360,6 +360,10 @@ int block_commits(THD *thd, TABLE_LIST *
{
DBUG_ENTER("block_commits()");
+ DBUG_EXECUTE_IF("backup_grl_fail",
+ /* Mimic behavior of a failing lock_global_read_lock */
+ DBUG_RETURN(1););
+
/*
Step 1 - global read lock.
*/
@@ -382,6 +386,12 @@ int block_commits(THD *thd, TABLE_LIST *
result= close_cached_tables(thd, 0, tables);
*/
+ DBUG_EXECUTE_IF("backup_grl_block_commit_fail",
+ /* Mimic behavior of a failing make_global_read_lock_block_commit */
+ unlock_global_read_lock(thd);
+ DBUG_RETURN(1);
+ );
+
/*
Step 3 - make the global read lock to block commits.
*/
@@ -402,13 +412,13 @@ int block_commits(THD *thd, TABLE_LIST *
@param thd (in) the current thread structure.
- @returns 0
+ This method cannot fail.
*/
-int unblock_commits(THD *thd)
+void unblock_commits(THD *thd)
{
DBUG_ENTER("unblock_commits()");
unlock_global_read_lock(thd);
- DBUG_RETURN(0);
+ DBUG_VOID_RETURN;
}
/**
@@ -652,7 +662,10 @@ int write_table_data(THD* thd, Backup_in
int error= 0;
error= block_commits(thd, NULL);
if (error)
+ {
+ log.report_error(ER_BACKUP_SYNCHRONIZE);
goto error;
+ }
if (sch.prepare()) // logs errors
goto error;
@@ -691,9 +704,7 @@ int write_table_data(THD* thd, Backup_in
Unblock commits.
*/
DEBUG_SYNC(thd, "before_backup_unblock_commit");
- error= unblock_commits(thd);
- if (error)
- goto error;
+ unblock_commits(thd);
report_vp_info(info);
=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt 2008-12-10 15:53:06 +0000
+++ b/sql/share/errmsg.txt 2008-12-15 09:22:24 +0000
@@ -6445,3 +6445,6 @@ ER_BACKUP_BACKUP_DBS
eng "Backing up %u database(s) %.220s"
ER_BACKUP_RESTORE_DBS
eng "Restoring %u database(s) %.220s"
+ER_BACKUP_SYNCHRONIZE
+ eng "Backup failed to synchronize table images."
+
| Thread |
|---|
| • bzr commit into mysql-6.0 branch (jorgen.loland:2737) Bug#40970 | Jorgen Loland | 15 Dec |