Bug #36933 Backup: snapshot error + crash if double backup
Submitted: 23 May 2008 22:10 Modified: 15 Nov 2008 1:26
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0.6-alpha-debug OS:Linux (SUSE 10 | 32-bit)
Assigned to: Rafal Somla CPU Architecture:Any

[23 May 2008 22:10] Peter Gulutzan
Description:
I create two InnoDB tables.
I backup twice, that is, I say
BACKUP DATABASE db_name, db_name ...;
I try to restore.

If the table contains only an INT,
I get ERROR 1661 (HY000):
Error when sending data to Snapshot restore driver

If the table contains an INT and a BLOB,
I get a crash.

One shouldn't say the same database name twice:
Bug#33567 Backup: duplicate database names allowed.
But this bug exhibits severe effects; the triage may differ.

How to repeat:
/* with only an INT -- Error 1661 */
create database k;
use k
create table i1 (s1 int, primary key (s1)) engine=innodb;
create table i2 (s1 int, primary key (s1)) engine=innodb;
insert into i1 values (2);
insert into i2 values (2);
backup database k,k to '1';
restore from '1';

/* with an INT and a BLOB -- crash */
create database l;
use l
create table i1 (s1 int, s2 blob, primary key (s1)) engine=innodb;
create table i2 (s1 int, s2 blob, primary key (s1)) engine=innodb;
insert into i1 values (2,'2');
insert into i2 values (2,'2');
backup database l,l to '2';
restore from '2';

Sample run:

mysql> create database k;
Query OK, 1 row affected (0.00 sec)

mysql> use k
Database changed
mysql> create table i1 (s1 int, primary key (s1)) engine=innodb;
Query OK, 0 rows affected (0.09 sec)

mysql> create table i2 (s1 int, primary key (s1)) engine=innodb;
Query OK, 0 rows affected (0.08 sec)

mysql> insert into i1 values (2);
Query OK, 1 row affected (0.02 sec)

mysql> insert into i2 values (2);
Query OK, 1 row affected (0.00 sec)

mysql> backup database k,k to '1';
+-----------+
| backup_id |
+-----------+
| 1         |
+-----------+
1 row in set (0.12 sec)

mysql> restore from '1';
ERROR 1661 (HY000): Error when sending data (for table #3) to Snapshot restore driver
mysql>
mysql> create database l;
Query OK, 1 row affected (0.01 sec)

mysql> use l
Database changed
mysql> create table i1 (s1 int, s2 blob, primary key (s1)) engine=innodb;
Query OK, 0 rows affected (0.07 sec)

mysql> create table i2 (s1 int, s2 blob, primary key (s1)) engine=innodb;
Query OK, 0 rows affected (0.06 sec)

mysql> insert into i1 values (2,'2');
Query OK, 1 row affected (0.01 sec)

mysql> insert into i2 values (2,'2');
Query OK, 1 row affected (0.02 sec)

mysql> backup database l,l to '2';
+-----------+
| backup_id |
+-----------+
| 3         |
+-----------+
1 row in set (0.13 sec)

mysql> restore from '2';
ERROR 2013 (HY000): Lost connection to MySQL server during query
[24 May 2008 18:43] MySQL Verification Team
Thank you for the bug report. Verified as described.
[5 Jun 2008 2:09] Hema Sridharan
I could see the crash after Restore of double backup only after inserting some values in the table i1.
[26 Sep 2008 8:27] Sergey Vojtovich
Reassigning to Rafal as discussed in Riga.
[24 Oct 2008 10:23] Rafal Somla
See also BUG#34480.
[24 Oct 2008 11:24] 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/56995

2717 Rafal Somla	2008-10-24
      BUG#36933, BUG#34480, BUG#33567 (Backup: snapshot error + crash if double backup)
      
      Before: When user specified the same database twice in the BACKUP DATABASE statement, 
      it was included twice in the backup image. This lead to a host of problems.
      
      After: BACKUP DATABASE will ignore duplicates in the database list. Each database,
      together with its objects, will be included only once in the produced backup image.
[24 Oct 2008 12:48] Jørgen Løland
Good to push
[31 Oct 2008 15:26] 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/57578

2717 Rafal Somla	2008-10-31
      BUG#36933, BUG#34480, BUG#33567 (Backup: snapshot error + crash if double 
      backup)
      
      Before: When user specified the same database twice in the BACKUP DATABASE 
      statement, it was included twice in the backup image. This lead to a host 
      of problems.
      
      After: 
      
      1. Parser reports error if the same database repeated twice in the list (similar 
      as for other SQL statements, e.g., DROP TABLE).
      
      2. Backup kernel code will ignore duplicates in the database list (if they ever
      get there) and never try to backup the same database twice.
[4 Nov 2008 13:35] Øystein Grøvlen
Good to push
[5 Nov 2008 9:42] 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/57862

2727 Rafal Somla	2008-11-05
      BUG#36933, BUG#34480, BUG#33567 (Backup: snapshot error + crash if double 
      backup)
      
      Before: When user specified the same database twice in the BACKUP DATABASE 
      statement, it was included twice in the backup image. This lead to a host 
      of problems.
      
      After: 
      
      1. Parser reports error if the same database repeated twice in the list (similar 
      as for other SQL statements, e.g., DROP TABLE).
      
      2. Backup kernel code will ignore duplicates in the database list (if they ever
      get there) and never try to backup the same database twice.
[5 Nov 2008 12:50] Rafal Somla
Pushed into team tree mysql-6.0-backup
[14 Nov 2008 14:49] Bugs System
Pushed into 6.0.9-alpha  (revid:rafal.somla@sun.com-20081105094115-zcpha090jreyw5jf) (version source revid:jorgen.loland@sun.com-20081114134411-xypyf8wyjc2nm3ly) (pib:5)
[15 Nov 2008 1:26] Paul DuBois
Noted in 6.0.9 changelog.

Specifying a database name twice to BACKUP DATABASE caused a server
crash. Now BACKUP DATABASE ignores duplicate names.