Skip to content

Commit ca032f3

Browse files
committed
#256 only force MDL X for certain alter table operations
1 parent 3625b93 commit ca032f3

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

storage/tokudb/ha_tokudb_alter_56.cc

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -720,27 +720,6 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i
720720
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
721721
bool result = false; // success
722722
THD *thd = ha_thd();
723-
MDL_ticket *ticket = table->mdl_ticket;
724-
if (ticket->get_type() != MDL_EXCLUSIVE) {
725-
// get exclusive lock no matter what
726-
#if defined(MARIADB_BASE_VERSION)
727-
killed_state saved_killed_state = thd->killed;
728-
thd->killed = NOT_KILLED;
729-
while (wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) && thd->killed)
730-
thd->killed = NOT_KILLED;
731-
assert(ticket->get_type() == MDL_EXCLUSIVE);
732-
if (thd->killed == NOT_KILLED)
733-
thd->killed = saved_killed_state;
734-
#else
735-
THD::killed_state saved_killed_state = thd->killed;
736-
thd->killed = THD::NOT_KILLED;
737-
while (wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) && thd->killed)
738-
thd->killed = THD::NOT_KILLED;
739-
assert(ticket->get_type() == MDL_EXCLUSIVE);
740-
if (thd->killed == THD::NOT_KILLED)
741-
thd->killed = saved_killed_state;
742-
#endif
743-
}
744723

745724
if (commit) {
746725
#if (50613 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
@@ -768,6 +747,35 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i
768747
}
769748

770749
if (!commit) {
750+
if (table->mdl_ticket->get_type() != MDL_EXCLUSIVE &&
751+
(ctx->add_index_changed || ctx->drop_index_changed || ctx->compression_changed)) {
752+
753+
// get exclusive lock no matter what
754+
#if defined(MARIADB_BASE_VERSION)
755+
killed_state saved_killed_state = thd->killed;
756+
thd->killed = NOT_KILLED;
757+
for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED); i++) {
758+
if (thd->killed != NOT_KILLED)
759+
thd->killed = NOT_KILLED;
760+
sleep(1);
761+
}
762+
assert(table->mdl_ticket->get_type() == MDL_EXCLUSIVE);
763+
if (thd->killed == NOT_KILLED)
764+
thd->killed = saved_killed_state;
765+
#else
766+
THD::killed_state saved_killed_state = thd->killed;
767+
thd->killed = THD::NOT_KILLED;
768+
for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED); i++) {
769+
if (thd->killed != THD::NOT_KILLED)
770+
thd->killed = THD::NOT_KILLED;
771+
sleep(1);
772+
}
773+
assert(table->mdl_ticket->get_type() == MDL_EXCLUSIVE);
774+
if (thd->killed == THD::NOT_KILLED)
775+
thd->killed = saved_killed_state;
776+
#endif
777+
}
778+
771779
// abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work.
772780
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton);
773781
assert(ctx->alter_txn == trx->stmt);

0 commit comments

Comments
 (0)