Bug #52076 Backup of partition and non-partition tables fail with native storage engine
Submitted: 15 Mar 2010 18:15 Modified: 5 Oct 2010 7:37
Reporter: Chuck Bell Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:5.5, 6.0 OS:Any
Assigned to: Chuck Bell CPU Architecture:Any

[15 Mar 2010 18:15] Chuck Bell
Description:
When a backup contains a partitioned table and a non-partitioned table for a storage engine that supports a native backup driver, it is possible if the non-partitioned table is included first in the backup stream that it will fail to switch the partitioned table to either the default or consistent snapshot driver. 

Note: related to now closed BUG#50697

How to repeat:
Run this test with PBXT:

create database p1;
use p1;
create table t1 (i int) engine=PBXT;
create table t2 (i int) engine=PBXT partition by hash(i) partitions 3;
backup database p1 to 'p1.bak';
SELECT * from mysql.backup_history;
drop database p1;
restore from 'p1.bak';
use p1;
show full tables;
drop database p1;

The test will fail on the backup step because only the native driver is chosen and the native driver is expecting a correct table name. The partitioned table names are not handled by native drivers and must be referenced via the partitioned storage engine.

Suggested fix:
There is a logic error in the code. It currently assumes if a native driver is present that there is no need to search for default drivers. But this is false given the scenario above. The code must be changed to permit the negotiation of a default or consistent snapshot driver for partitioned tables.
[15 Mar 2010 18:20] 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/103298

3111 Chuck Bell	2010-03-15
      BUG#52076 : Backup of partition and non-partition tables fail with native storage engine
      
      When a backup contains a partitioned table and a non-partitioned table for a 
      storage engine that supports a native backup driver, it is possible if the 
      non-partitioned table is included first in the backup stream that it will 
      fail to switch the partitioned table to either the default or consistent 
      snapshot driver. 
      
      This patch corrects a logic error in the code and permits the selection of the
      default or consistent snapshot driver in the event a table contains partitions
      and the native driver has already been identified.
     @ mysql-test/suite/backup/r/backup_native_partition.result
        New result file.
     @ mysql-test/suite/backup/t/backup_native_partition.test
        New test file containing test case to ensure default driver is
        selected even though a partition and non-partition MyISAM table
        has been included in the backup.
     @ sql/backup/backup_info.cc
        Added check for table has partitions for the default driver selection
        code to allow for the case when a native driver has been chosen and
        the backup contains a partitioned table of the same storage engine.
        
        In this case, we select the default or consistent snapshot driver
        for the partitioned table and skip the native driver.
[16 Mar 2010 10:24] Ingo Strüwing
Not approved. Please see email.
[19 Mar 2010 18:32] 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/103875

3111 Chuck Bell	2010-03-19
      BUG#52076 : Backup of partition and non-partition tables fail with native storage engine
      
      When a backup contains a partitioned table and a non-partitioned table for a 
      storage engine that supports a native backup driver, it is possible if the 
      non-partitioned table is included first in the backup stream that it will 
      fail to switch the partitioned table to either the default or consistent 
      snapshot driver. 
      
      This patch corrects a logic error in the code and permits the selection of the
      default or consistent snapshot driver in the event a table contains partitions
      and the native driver has already been identified.
     @ mysql-test/suite/backup/r/backup_native_partition.result
        New result file.
     @ mysql-test/suite/backup/t/backup_native_partition.test
        New test file containing test case to ensure default driver is
        selected even though a partition and non-partition MyISAM table
        has been included in the backup.
     @ sql/backup/backup_info.cc
        Added check for table has partitions for the default driver selection
        code to allow for the case when a native driver has been chosen and
        the backup contains a partitioned table of the same storage engine.
        
        In this case, we select the default or consistent snapshot driver
        for the partitioned table and skip the native driver.
[24 Mar 2010 17:24] Ingo Strüwing
My main concern is not fixed yet. Tests pass even without the code fix.
[5 Oct 2010 7:37] Ingo Strüwing
The feature will not be implemented.