List:Commits« Previous MessageNext Message »
From:ingo Date:May 11 2006 10:21am
Subject:bk commit into 5.0 tree (ingo:1.2123) BUG#19604
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mydev. When mydev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2123 06/05/11 12:21:46 ingo@stripped +5 -0
  Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
  
  CHECK TABLE did temporarily clear the auto_increment value.
  It runs with a read lock, allowing other readers and
  conurrent INSERTs. The latter could grab the wrong value
  in this moment.
  
  CHECK TABLE does no longer modify the auto_increment value.
  Not even for a short moment.

  myisam/myisamdef.h
    1.84 06/05/11 12:21:40 ingo@stripped +1 -1
    Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
    Changed update_auto_increment() to retrieve_auto_increment()
    to reflect that it does not change the auto_increment by
    itself any more. This must now be done externally if needed.

  myisam/mi_write.c
    1.57 06/05/11 12:21:40 ingo@stripped +2 -1
    Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
    Added explicit update of info->s->state.auto_increment
    after the change from update_auto_increment() to
    retrieve_auto_increment().

  myisam/mi_update.c
    1.21 06/05/11 12:21:40 ingo@stripped +2 -1
    Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
    Added explicit update of info->s->state.auto_increment
    after the change from update_auto_increment() to
    retrieve_auto_increment().

  myisam/mi_key.c
    1.50 06/05/11 12:21:40 ingo@stripped +6 -8
    Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
    Changed update_auto_increment() to retrieve_auto_increment()
    to reflect that it does not change the auto_increment by
    itself any more. This must now be done externally if needed.

  myisam/mi_check.c
    1.143 06/05/11 12:21:40 ingo@stripped +14 -16
    Bug#19604 - CHECK TABLE with concurrent INSERT can reset auto_increment
    In chk_key() and update_auto_increment_key() in the repair_only
    case, do not touch info->s->state.auto_increment. Especially
    chk_key() can be called from CHECK TABLE with a read lock.
    Concurrent inserts could grab a temporarily changed value.
    Added minor style fixes.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.0-bug19604

--- 1.142/myisam/mi_check.c	2006-05-02 11:01:32 +02:00
+++ 1.143/myisam/mi_check.c	2006-05-11 12:21:40 +02:00
@@ -453,25 +453,24 @@
     if ((uint) share->base.auto_key -1 == key)
     {
       /* Check that auto_increment key is bigger than max key value */
-      ulonglong save_auto_value=info->s->state.auto_increment;
-      info->s->state.auto_increment=0;
+      ulonglong auto_increment;
       info->lastinx=key;
       _mi_read_key_record(info, 0L, info->rec_buff);
-      update_auto_increment(info, info->rec_buff);
-      if (info->s->state.auto_increment > save_auto_value)
+      auto_increment= retrieve_auto_increment(info, info->rec_buff);
+      if (auto_increment > info->s->state.auto_increment)
       {
-	mi_check_print_warning(param,
-			       "Auto-increment value: %s is smaller than max used value: %s",
-			       llstr(save_auto_value,buff2),
-			       llstr(info->s->state.auto_increment, buff));
+	mi_check_print_warning(param, "Auto-increment value: %s is smaller "
+                               "than max used value: %s",
+			       llstr(info->s->state.auto_increment,buff2),
+			       llstr(auto_increment, buff));
       }
       if (param->testflag & T_AUTO_INC)
       {
 	set_if_bigger(info->s->state.auto_increment,
+		      auto_increment);
+	set_if_bigger(info->s->state.auto_increment,
 		      param->auto_increment_value);
       }
-      else
-	info->s->state.auto_increment=save_auto_value;
 
       /* Check that there isn't a row with auto_increment = 0 in the table */
       mi_extra(info,HA_EXTRA_KEYREAD,0);
@@ -481,8 +480,8 @@
       {
 	/* Don't count this as a real warning, as myisamchk can't correct it */
 	uint save=param->warning_printed;
-	mi_check_print_warning(param,
-			       "Found row where the auto_increment column has the value 0");
+	mi_check_print_warning(param, "Found row where the auto_increment "
+                               "column has the value 0");
 	param->warning_printed=save;
       }
       mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
@@ -4099,11 +4098,10 @@
   }
   else
   {
-    ulonglong auto_increment= (repair_only ? info->s->state.auto_increment :
-			       param->auto_increment_value);
-    info->s->state.auto_increment=0;
-    update_auto_increment(info, record);
+    ulonglong auto_increment= retrieve_auto_increment(info, record);
     set_if_bigger(info->s->state.auto_increment,auto_increment);
+    if (! repair_only)
+      set_if_bigger(info->s->state.auto_increment, param->auto_increment_value);
   }
   mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
   my_free((char*) record, MYF(0));

--- 1.49/myisam/mi_key.c	2006-04-27 09:51:29 +02:00
+++ 1.50/myisam/mi_key.c	2006-05-11 12:21:40 +02:00
@@ -507,22 +507,21 @@
   return(-1);				/* Wrong data to read */
 }
 
-  
+
 /*
-  Update auto_increment info
+  Retrieve auto_increment info
 
   SYNOPSIS
-    update_auto_increment()
+    retrieve_auto_increment()
     info			MyISAM handler
     record			Row to update
 
   IMPLEMENTATION
-    Only replace the auto_increment value if it is higher than the previous
-    one. For signed columns we don't update the auto increment value if it's
+    For signed columns we don't retrieve the auto increment value if it's
     less than zero.
 */
 
-void update_auto_increment(MI_INFO *info,const byte *record)
+ulonglong retrieve_auto_increment(MI_INFO *info,const byte *record)
 {
   ulonglong value= 0;			/* Store unsigned values here */
   longlong s_value= 0;			/* Store signed values here */
@@ -587,6 +586,5 @@
     and if s_value == 0 then value will contain either s_value or the
     correct value.
   */
-  set_if_bigger(info->s->state.auto_increment,
-                (s_value > 0) ? (ulonglong) s_value : value);
+  return (s_value > 0) ? (ulonglong) s_value : value;
 }

--- 1.20/myisam/mi_update.c	2006-03-10 15:04:04 +01:00
+++ 1.21/myisam/mi_update.c	2006-05-11 12:21:40 +02:00
@@ -164,7 +164,8 @@
       key_changed|= HA_STATE_CHANGED;		/* Must update index file */
   }
   if (auto_key_changed)
-    update_auto_increment(info,newrec);
+    set_if_bigger(info->s->state.auto_increment,
+                  retrieve_auto_increment(info, newrec));
   if (share->calc_checksum)
     info->state->checksum+=(info->checksum - old_checksum);
 

--- 1.56/myisam/mi_write.c	2006-03-10 15:04:04 +01:00
+++ 1.57/myisam/mi_write.c	2006-05-11 12:21:40 +02:00
@@ -149,7 +149,8 @@
     info->state->checksum+=info->checksum;
   }
   if (share->base.auto_key)
-    update_auto_increment(info,record);
+    set_if_bigger(info->s->state.auto_increment,
+                  retrieve_auto_increment(info, record));
   info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
 		 HA_STATE_ROW_CHANGED);
   info->state->records++;

--- 1.83/myisam/myisamdef.h	2005-10-27 19:04:31 +02:00
+++ 1.84/myisam/myisamdef.h	2006-05-11 12:21:40 +02:00
@@ -582,7 +582,7 @@
 extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf);
 extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos,
 			  uint length,int re_read_if_possibly);
-extern void update_auto_increment(MI_INFO *info,const byte *record);
+extern ulonglong retrieve_auto_increment(MI_INFO *info,const byte *record);
 
 extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**);
 #define mi_get_rec_buff_ptr(info,buf)                              \
Thread
bk commit into 5.0 tree (ingo:1.2123) BUG#19604ingo11 May