Commit 5cff2592 authored by marko's avatar marko

branches/zip: ha_innobase::add_index(): Fix a race condition that

existed before the fast-index-creation code was merged, in r1414.

Do not call row_prebuilt_table_obsolete(innodb_table) until after
the table has been renamed to a temporary name.  Otherwise, the
following could happen when creating a clustered index on table T:

(a1) copy T to T#1
(a2) mark T obsolete
(b1) add the name of T to the background drop list
(a3) rename T to T#2 and T#1 to T
(b2) drop the table on the background

These steps are executed by two threads, a and b.

If b1 is executed after a3, all is fine: the name T#2 will be added
to the background drop list.  If b1 is executed before a3, the name
T will be added, and T#2 will survive.
parent cee36690
......@@ -8489,8 +8489,6 @@ ha_innobase::add_index(
row_mysql_lock_data_dictionary(trx);
dict_locked = TRUE;
row_prebuilt_table_obsolete(innodb_table);
error = row_merge_rename_tables(innodb_table, indexed_table,
tmp_name, trx);
......@@ -8512,6 +8510,8 @@ ha_innobase::add_index(
break;
}
row_prebuilt_table_obsolete(innodb_table);
row_prebuilt_free(prebuilt, TRUE);
prebuilt = row_create_prebuilt(indexed_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment