Bug #34767 | Existing DB contents are lost, if I attempt to restore a corrupted backup file. | ||
---|---|---|---|
Submitted: | 22 Feb 2008 20:58 | Modified: | 13 Nov 2008 16:12 |
Reporter: | Hema Sridharan | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Backup | Severity: | S1 (Critical) |
Version: | mysql-6.0-backup | OS: | Linux |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
[22 Feb 2008 20:58]
Hema Sridharan
[22 Feb 2008 21:23]
Sveta Smirnova
Thank you for the report. Verified as described using following test: create database err; use err; create table t1(id int); insert into t1 values(1); create table t2(id int); --eval backup database err to '$MYSQL_TEST_DIR/var/tmp/errtry' drop database err; --eval restore from '$MYSQL_TEST_DIR/var/tmp/errtry' show databases; show tables from err; --exec head -n 2 $MYSQL_TEST_DIR/var/tmp/errtry > $MYSQL_TEST_DIR/var/tmp/errtry2 --error 1064 --eval restore from '$MYSQL_TEST_DIR/var/tmp/errtry2' show databases; show tables from err;
[26 Feb 2008 15:09]
Lars Thalmann
POSSIBLE PROBLEMS ================= 1. Failed restore should not corrupt existing database. 2. Restore should immediately fail if backup image is corrupt. 3. Errors messages shown are internal, not an error message corresponding to the RESTORE statement SOLUTION ======== 1. This is documented as a limitation. Hema will check with Peter if this "best-effort" approach is not enough. 2. There is no checksum implemented yet. 3. Should probably be fixed.
[6 Mar 2008 5:04]
Hema Sridharan
( From the email of Peter Gulutzan) I conclude that Hema's requirement "this should be fixed (FAILED RESTORE SHOULDN'T HAVE ANY EFFECT ON YOUR CURRENT DATABASE)" is not the plan, and MySQL's "best effort" is enough. Hema is right that a failed recovery is a "disaster". So MySQL should improve RESTORE ... 1. Checksums, as Lars mentioned in the Bug#34767 comment 2. RESTORE ... VALIDATE, as in Oracle RMAN i.e. run through the backup without changing anything http://www.itk.ilstu.edu/docs/Oracle/server.101/b10770/rcmsynta51.htm 3. RESTORE ... PREVIEW, though not quite as in Oracle i.e. MySQL's response from RESTORE ... PREVIEW is "I will drop the following old existing database: x. I will create the following new database: x. I will destroy x files and y objects while doing this." 4. Instead of "drop old directory then add new one", do "add new directory, then drop old directory, then rename". 5. Do not stop RESTORE when you see an error in the file. Try to skip the error and continue. This might require an additional keyword, FORCE. 6. Have a cautious mode where destruction is not possible i.e. if database directory exists it can't be dropped. E.g. RESTORE FROM 'x.bak' CAREFULLY!; will fail with error "existing database wasn't dropped". 7. Implemen non-destructive mode mentioned in worklog task descriptions. Developers are aware that failed recovery is a "disaster". So improving RESTORE should be on the roadmap.
[29 Oct 2008 9:52]
Jørgen Løland
Problem 1 - database corrupted: Best effort is not on the plan for 6.0 Problem 2 - fail immediately if corrupted image: Checksums is not on the plan for 6.0, tracked by WL#4385 Problem 3 - internal error message: Will be fixed this this bug report.
[11 Nov 2008 11:49]
Jørgen Løland
The error message for restore in the original posting: "ERROR 1064 (42000): You have an error in your SQL syntax;..." has already been changed. The error message is now: "ERROR 1677 (HY000): Could not restore table `err`.`t1`"
[13 Nov 2008 10:29]
Jørgen Løland
Since error message is ok now, there is nothing left to do. Error message was fixed in 6.0.7
[13 Nov 2008 16:12]
Paul DuBois
Cosmetic change regarding error message only; original problem still exists. No changelog entry needed.