Bug #39354 Falcon: Rename table corrupts index mapping
Submitted: 9 Sep 2008 22:59 Modified: 9 Jan 2009 14:12
Reporter: Christopher Powers Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S1 (Critical)
Version:6.0-falcon OS:Any
Assigned to: Christopher Powers CPU Architecture:Any
Triage: Triaged: D1 (Critical)

[9 Sep 2008 22:59] Christopher Powers
Description:
The StorageInterface maintains a mapping between the MySQL indexes and the corresponding Falcon indexes. Each Falcon index is given a unique internal name prefixed with the table name.

Falcon/MySQL indexes are not always remapped following a rename table operation, resulting in a crash or runtime assertion. Tables are commonly renamed during offline ALTERs when existing tables are renamed and replaced with temporary tables.

How to repeat:
System QA stress test "falcon_online_alter"

Suggested fix:
Remap indexes in StorageInterface::rename_table(): 

StorageInterface::rename_table(...)
{
   [...]
   int ret = open(from, 0, 0);

+  storageTable->clearCurrentIndex();
+  storageShare->lockIndexes(true);
+  storageShare->lock(true);

   ret = storageShare->renameTable(storageConnection, to);
	
+  remapIndexes(table);
	
+  storageShare->unlock();
+  storageShare->unlockIndexes();

   DBUG_RETURN(ret);
}
[9 Sep 2008 23:00] Christopher Powers
Verified while debugging stress test failures.
[9 Sep 2008 23:18] 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/53647

2814 Christopher Powers	2008-09-09
      Bug#39347 Falcon: Online add/drop unique index fails
      Bug#39349 Falcon: Online drop index conflicts with other index operations
      Bug#39354 Falcon: Rename table corrupts index mapping
      
      - Enabled HA_ADD/DROP_UNIQUE_INDEX
      - Don't create StorageIndexDesc objects if internal falcon index does not exist
      - Rebuild index mapping when table is renamed
      - Added validation methods to detect out-of-sync condition between server and falcon indexes
[9 Sep 2008 23:21] 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/53648

2814 Christopher Powers	2008-09-09
      Bug#39347 Falcon: Online add/drop unique index fails
      Bug#39349 Falcon: Online drop index conflicts with other index operations
      Bug#39354 Falcon: Rename table corrupts index mapping
      
      - Enabled HA_ADD/DROP_UNIQUE_INDEX
      - Don't create StorageIndexDesc objects if internal falcon index does not exist
      - Rebuild index mapping when table is renamed
      - Added validation methods to detect out-of-sync condition between server and falcon indexes
[9 Sep 2008 23:23] 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/53649

2814 Christopher Powers	2008-09-09
      Bug#39347 Falcon: Online add/drop unique index fails
      Bug#39349 Falcon: Online drop index conflicts with other index operations
      Bug#39354 Falcon: Rename table corrupts index mapping
      
      - Enabled HA_ADD/DROP_UNIQUE_INDEX
      - Don't create StorageIndexDesc objects if internal falcon index does not exist
      - Rebuild index mapping when table is renamed
      - Added validation methods to detect out-of-sync condition between server and falcon indexes
[9 Jan 2009 14:12] MC Brown
A note has been added to the 6.0.7 changelog: 

When renaming a Falcon table the corresponding indexes could become corrupt or unavailable