List:Maria Storage Engine« Previous MessageNext Message »
From:Guilhem Bichot Date:July 9 2008 12:38pm
Subject:bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2659) Bug#37873
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/

 2659 Guilhem Bichot	2008-07-09
      first try of fix for BUG#37873 "Client gets ok from INSERT VALUES before commit record is on disk".
      Without the fix, the added assertion in ha_maria::external_lock() fires many times in *maria*.test
modified:
  sql/sql_parse.cc
  storage/maria/ha_maria.cc
  storage/maria/ha_maria.h

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-07-09 12:07:38 +0000
+++ b/sql/sql_parse.cc	2008-07-09 12:38:04 +0000
@@ -127,7 +127,7 @@ bool end_active_trans(THD *thd)
     if (ha_commit(thd))
       error=1;
 #ifdef WITH_MARIA_STORAGE_ENGINE
-    ha_maria::implicit_commit(thd);
+    ha_maria::implicit_commit(thd, TRUE);
 #endif
   }
   thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
@@ -1132,6 +1132,10 @@ bool dispatch_command(enum enum_server_c
     {
       char *beginning_of_next_stmt= (char*) end_of_stmt;
 
+#ifdef WITH_MARIA_STORAGE_ENGINE
+      ha_maria::implicit_commit(thd, FALSE);
+#endif
+
       net_end_statement(thd);
       query_cache_end_of_result(thd);
       /*
@@ -1496,6 +1500,10 @@ bool dispatch_command(enum enum_server_c
     thd->mysys_var->abort= 0;
   }
 
+#ifdef WITH_MARIA_STORAGE_ENGINE
+  ha_maria::implicit_commit(thd, FALSE);
+#endif
+
   net_end_statement(thd);
   query_cache_end_of_result(thd);
 

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2008-07-09 12:07:38 +0000
+++ b/storage/maria/ha_maria.cc	2008-07-09 12:38:04 +0000
@@ -2342,6 +2342,8 @@ int ha_maria::external_lock(THD *thd, in
       {
         if (!trnman_decrement_locked_tables(trn))
         {
+          /* OK should not have been sent to client yet (ACID): */
+          DBUG_ASSERT(!thd->main_da.is_sent);
           /* autocommit ? rollback a transaction */
 #ifdef MARIA_CANNOT_ROLLBACK
           if (ma_commit(trn))
@@ -2405,7 +2407,7 @@ int ha_maria::start_stmt(THD *thd, thr_l
   without need to call this function which can then be removed.
 */
 
-int ha_maria::implicit_commit(THD *thd)
+int ha_maria::implicit_commit(THD *thd, bool new_trn)
 {
 #ifndef MARIA_CANNOT_ROLLBACK
 #error this method should be removed
@@ -2414,11 +2416,18 @@ int ha_maria::implicit_commit(THD *thd)
   int error= 0;
   TABLE *table;
   DBUG_ENTER("ha_maria::implicit_commit");
+  if (thd->locked_tables && !new_trn)
+    DBUG_RETURN(0);
   if ((trn= THD_TRN) != NULL)
   {
     uint locked_tables= trnman_has_locked_tables(trn);
     if (unlikely(ma_commit(trn)))
       error= 1;
+    if (!new_trn)
+    {
+      THD_TRN= NULL;
+      goto end;
+    }
     /*
       We need to create a new transaction and put it in THD_TRN. Indeed,
       tables may be under LOCK TABLES, and so they will start the next
@@ -2458,6 +2467,7 @@ int ha_maria::implicit_commit(THD *thd)
       }
     }
   }
+end:
   DBUG_RETURN(error);
 }
 

=== modified file 'storage/maria/ha_maria.h'
--- a/storage/maria/ha_maria.h	2008-06-28 08:27:14 +0000
+++ b/storage/maria/ha_maria.h	2008-07-09 12:38:04 +0000
@@ -161,5 +161,5 @@ public:
   {
     return file;
   }
-  static int implicit_commit(THD *thd);
+  static int implicit_commit(THD *thd, bool new_trn);
 };

Thread
bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2659) Bug#37873Guilhem Bichot9 Jul