@@ -720,27 +720,6 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i
720
720
tokudb_alter_ctx *ctx = static_cast <tokudb_alter_ctx *>(ha_alter_info->handler_ctx );
721
721
bool result = false ; // success
722
722
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
- }
744
723
745
724
if (commit) {
746
725
#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
768
747
}
769
748
770
749
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
+
771
779
// abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work.
772
780
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data (thd, tokudb_hton);
773
781
assert (ctx->alter_txn == trx->stmt );
0 commit comments