#At file:///localhome/jl208045/mysql/mysql-6.0-backup-40970/
2740 Jorgen Loland 2008-12-05
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-11-25 17:44:19 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result 2008-12-05 09:00:57 +0000
@@ -216,4 +216,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-11-25 17:44:19 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test 2008-12-05 09:00:57 +0000
@@ -367,4 +367,24 @@ 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';
+--replace_column 1 #
+--error ER_BACKUP_SYNCHRONIZE
+BACKUP DATABASE db1 TO 'overwrite1.bak';
+SET SESSION DEBUG='-d';
+
+--echo
+
+SET SESSION DEBUG='+d,backup_grl_block_commit_fail';
+--replace_column 1 #
+--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-05 09:00:57 +0000
@@ -360,6 +360,13 @@ int block_commits(THD *thd, TABLE_LIST *
{
DBUG_ENTER("block_commits()");
+
+ /*
+ Simulate an error condition for failure of the
+ lock_global_read_lock call.
+ */
+ DBUG_EXECUTE_IF("backup_grl_fail", DBUG_RETURN(1););
+
/*
Step 1 - global read lock.
*/
@@ -383,6 +390,18 @@ int block_commits(THD *thd, TABLE_LIST *
*/
/*
+ Simulate an error condition for failure of the
+ make_global_read_lock_block_commit call.
+ */
+ 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.
*/
if (make_global_read_lock_block_commit(thd))
@@ -402,13 +421,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 +671,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 +713,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-11-28 10:10:39 +0000
+++ b/sql/share/errmsg.txt 2008-12-05 09:00:57 +0000
@@ -6442,3 +6442,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."
+