Bug #42402 Restore crashes server if tablespace does not exist
Submitted: 28 Jan 2009 8:53 Modified: 30 Mar 2009 1:55
Reporter: Jørgen Løland Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S2 (Serious)
Version:6.0 OS:Any
Assigned to: Jørgen Løland CPU Architecture:Any

[28 Jan 2009 8:53] Jørgen Løland
Description:
Restore crashes the server if the backup image contains tables originally stored in a tablespace that is no longer around.

How to repeat:
create tablespace tb add datafile 'tblspace' engine=falcon;
create database wa;
use wa;

create table t (s1 int) engine=falcon tablespace tb;
insert into t values (1);

--replace_column 1 #
backup database wa to '1.bup';

drop database wa;
drop tablespace tb engine=falcon;

restore from '1.bup';
--> crash

Suggested fix:
The problem is in si_objects.cc:find_tablespace

The current code assumes that there will be exactly one tablespace with this name in the server, otherwise an assertion is triggered:

2722: DBUG_ASSERT(ed_result_set->size() == 1);

However, it is ok for this method to return nothing. The backup code is written to handle this case, and will try to create the tablespace.
[28 Jan 2009 10:21] MySQL Verification Team
mysql> drop database wa;
Query OK, 1 row affected (0.01 sec)

mysql> drop tablespace tb engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> restore from '1.bup';
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[5 Mar 2009 13:51] 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/68387

2784 Jorgen Loland	2009-03-05
      Bug#42402 - Restore crashes server if tablespace does not exist
      
      Before, RESTORE would crash if the backup image contained tables originally stored in a tablespace that no longer exists at RESTORE time.
      
      With this patch, the tablespace is recreated like it was at BACKUP time if it does not exist when RESTORE is executed.
[6 Mar 2009 9:31] Rafal Somla
Good to push.
[6 Mar 2009 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/68462

2790 Jorgen Loland	2009-03-06
      Bug#42402 - Restore crashes server if tablespace does not exist
            
      Before, RESTORE would crash if the backup image contained tables originally stored
      in a tablespace that no longer exists at RESTORE time.
            
      With this patch, the tablespace is recreated like it was at BACKUP time if it does
      not exist when RESTORE is executed.
[26 Mar 2009 12:34] Bugs System
Pushed into 6.0.11-alpha (revid:alik@sun.com-20090326121822-pt84kzxxayzho4mn) (version source revid:charles.bell@sun.com-20090309134019-vr480npdp30f2gvh) (merge vers: 6.0.11-alpha) (pib:6)
[30 Mar 2009 1:55] Paul DuBois
Noted in 6.0.11 changelog.

Previously, RESTORE would crash if the backup image contained tables
originally stored in a tablespace that no longer existed at RESTORE
time. Now the tablespace is recreated like it was at BACKUP DATABASE
time if it does not exist when RESTORE is executed.