Bug #39016 backup_db_grants test failing in pushbuild
Submitted: 25 Aug 2008 17:23 Modified: 25 Oct 2009 21:00
Reporter: Chuck Bell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0.7-backup OS:Any
Assigned to: Jørgen Løland CPU Architecture:Any
Tags: disabled

[25 Aug 2008 17:23] Chuck Bell
Description:
The test backup_db_grants is failing in the mysql-6.0-backup tree on machines 'sol10-sparc-a' -max, 'win2003-x86' -max-nt, and 'vm-win2003-64-b' Win64 VS2005 -max-nt.

The 'sol10-sparc-a' -max, and 'vm-win2003-64-b' Win64 VS2005 -max-nt machines generate an error because the output of the expected error message is garbage:

-ERROR HY000: The grant 'GRANT SELECT ON boo_db_grants.* TO 'bup_user1'@'%' failed. Database not included in the backup image.
+ERROR HY000: The grant '^�' failed. Database not included in the backup image.

This problem has been traced to a bug in the error reporting mechanism in backup for 64-bit machines. While it is possible to overcome this by restructuring the code, it is apparent the backup error reporting is not working correctly on all platforms.

The 'win2003-x86' -max-nt machine fails because the RESTORE command for the modified backup file fails with a different error message:

mysqltest: At line 111: query 'RESTORE FROM 'bup_db_grants.bak'' failed with wrong errno 1677: 'Could not restore table `bup_db_grants`.`s1`', instead of 1732...

This is likely due to the fact that the perl command in the test is not working correctly. It appears that the modified SQL statement in the backup image is not being modified correctly.

How to repeat:
Run backup_db_grants test on the machines described above or see the mysql-6.0-backup tree for details.

Suggested fix:
Correct the error reporting bug for 64-bit machines and change the perl command to something that works on all platforms. Note: sed will not work because it does not work on Solaris.

Another possible solution is to change the test to use debug insertion. The changes needed for this method are:

=== modified file 'mysql-test/t/backup_db_grants.test'
--- mysql-test/t/backup_db_grants.test  2008-08-21 19:28:49 +0000
+++ mysql-test/t/backup_db_grants.test  2008-08-25 16:57:26 +0000
@@ -4,6 +4,7 @@

 --source include/not_embedded.inc
 --source include/have_sjis.inc
+--source include/have_debug.inc

 --disable_warnings
 DROP DATABASE IF EXISTS bup_db_grants;
@@ -105,11 +106,15 @@ SHOW GRANTS FOR 'no_user'@'%';

 --echo Now demonstrate what happens when grants are altered in backup image.

---exec perl -pi.bak -e "s/ON bup/ON boo/" $MYSQLTEST_VARDIR/master-data/bup_db_
grants.bak
+SET GLOBAL debug="d,backup_test_wrong_db";
+SELECT @@global.debug;
+
 --echo Run Restore
 --error ER_BACKUP_GRANT_WRONG_DB
 RESTORE FROM 'bup_db_grants.bak';

+SET GLOBAL debug="d,";
+
 FLUSH PRIVILEGES;

 --echo Cleanup
@@ -126,8 +131,6 @@ DROP USER 'no_user'@'%';
 FLUSH PRIVILEGES;

 --remove_file $MYSQLTEST_VARDIR/master-data/bup_db_grants.bak
-
---remove_file $MYSQLTEST_VARDIR/master-data/bup_db_grants.bak.bak

 --echo Now test for encoded user names with an x40 in the middle.

=== modified file 'mysql-test/t/backup_default.test'
--- mysql-test/t/backup_default.test    2008-08-18 08:25:56 +0000
+++ mysql-test/t/backup_default.test    2008-08-22 21:33:23 +0000
@@ -4,6 +4,7 @@
 --source include/have_falcon.inc
 --source include/have_partition.inc
 --source include/not_embedded.inc
+--source include/query_cache.inc

 --echo
 --echo Server should not crash for backup using default driver - CSV
@@ -99,12 +100,15 @@ ENGINE=myisam;

 INSERT INTO myisam_table VALUES(1,'v1'),(2,'v2'),(3,'v3');

+flush_query_cache;
+
 --echo backup on mixed table database
 --replace_column 1 #
 BACKUP DATABASE db1 to 'bup_mixed.bak';

 DROP DATABASE db1;

+flush_query_cache;
 --echo restore on mixed table database
 --replace_column 1 #
 RESTORE FROM 'bup_mixed.bak';

=== modified file 'sql/backup/kernel.cc'
--- sql/backup/kernel.cc        2008-08-21 11:36:09 +0000
+++ sql/backup/kernel.cc        2008-08-25 17:10:56 +0000
@@ -1816,6 +1816,14 @@ int bcat_create_item(st_bstream_image_he
     db_name.alloc(size);
     db_name.length(0);
     db_name.append(start, size);
+    DBUG_EXECUTE_IF("backup_test_wrong_db",
+    {
+      db_name.length(0);
+      db_name.append("boo_db_grants");
+      start=  strstr((char *)create_stmt.begin, "bup_db_grants");
+      strcpy(start, "boo_db_grants");
+      start[13]= '.';
+    });
     if (!info->has_db(db_name))
     {
       info->m_ctx.fatal_error(ER_BACKUP_GRANT_WRONG_DB, create_stmt);
[25 Aug 2008 17:24] Chuck Bell
In the interest of moving forward, the section of the test WRT testing the modification of the grant statements in the backup image file has been disabled. See the test for details.
[26 Aug 2008 19:17] Sveta Smirnova
Thank you for the report.

Verified as described with backup_db_grants from revision 2681
[26 Aug 2009 12:56] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/81610

2865 Jorgen Loland	2009-08-26
      Bug#39016 - backup_db_grants test failing in pushbuild
      
      This part of the test failed on some platforms when perl was 
      used to modify a GRANT statement in the backup image before 
      running restore. The goal was to check that the tampering was 
      detected.
      
      It has since been decided that backup image tampering must be
      prevented in other ways, so the code this part of the test
      was written for no longer exists. This patch removes the failing
      test.
     @ mysql-test/suite/backup/t/backup_db_grants.test
        Remove part of test that checked if backup images where a GRANT statement had been tampered with were rejected. The code that did this checking on longer exists.
[26 Aug 2009 13:36] Chuck Bell
Patch approved. Only one reviewer needed.
[25 Oct 2009 13:37] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091025133616-ca4inerav4vpdnaz) (version source revid:ingo.struewing@sun.com-20090908195642-dtq0vxjcjk6e11w4) (merge vers: 5.4.4-alpha) (pib:13)
[25 Oct 2009 21:00] Paul DuBois
Test case changes. No changelog entry needed.