List:Internals« Previous MessageNext Message »
From:Zardosht Kasheff Date:July 24 2010 1:45am
Subject:Re: [feedback/review request] Re: index creation and concurrent reads
View as plain text  
Hello all,

After some investigation, I think the attached patch solves the issue.
I am interested in hearing feedback on the patch.

Thanks
-Zardosht

>> Hello all,
>>
>> About a year and a half ago, I filed the following bug:
>> http://bugs.mysql.com/bug.php?id=42230
>>
>> In short, for storage engines that implement handler::add_index,
>> queries cannot be run on a table while an index is being created. This
>> affects the innodb plugin.
>>
>> A comment at the bottom of the bug states that there is a "one line
>> fix". Does anyone have any ideas as to what that one line fix may be?
>> This bug seems important because storage engines that do NOT implement
>> handler::add_index do not have this problem.
>>
>> Thanks
>> -Zardosht
>>
>

Index: sql_table.cc
===================================================================
--- sql_table.cc	(revision 21155)
+++ sql_table.cc	(working copy)
@@ -5973,6 +5973,9 @@
 
   switch (keys_onoff) {
   case ENABLE:
+    VOID(pthread_mutex_lock(&LOCK_open));
+    wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
+    VOID(pthread_mutex_unlock(&LOCK_open));
     error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
     break;
   case LEAVE_AS_IS:
@@ -5980,6 +5983,9 @@
       break;
     /* fall-through: disabled indexes */
   case DISABLE:
+    VOID(pthread_mutex_lock(&LOCK_open));
+    wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
+    VOID(pthread_mutex_unlock(&LOCK_open));
     error= table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
   }
 
@@ -7231,9 +7237,6 @@
   }
   else
   {
-    VOID(pthread_mutex_lock(&LOCK_open));
-    wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
-    VOID(pthread_mutex_unlock(&LOCK_open));
     thd_proc_info(thd, "manage keys");
     alter_table_manage_keys(table, table->file->indexes_are_disabled(),
                             alter_info->keys_onoff);
Thread
Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff24 Jul
  • Re: [feedback/review request] Re: index creation and concurrent readsDavi Arnaut24 Jul
    • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff24 Jul
      • Re: [feedback/review request] Re: index creation and concurrent readsDavi Arnaut24 Jul
        • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff24 Jul
    • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff22 Oct
      • Re: [feedback/review request] Re: index creation and concurrent readsDavi Arnaut22 Oct
        • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff22 Oct
          • Re: [feedback/review request] Re: index creation and concurrent readsDavi Arnaut22 Oct
            • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff22 Oct
              • Re: [feedback/review request] Re: index creation and concurrentreadsSergey Vojtovich25 Oct
                • Re: [feedback/review request] Re: index creation and concurrent readsZardosht Kasheff25 Oct
                  • Re: [feedback/review request] Re: index creation and concurrentreadsSergey Vojtovich25 Oct