[Commits] Rev 3461: MDEV-232: Fix uninitialised variable reference when --binlog-optimize-thread-scheduling=0 in http://bazaar.launchpad.net/~maria-captains/maria/5.5

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Wed Sep 5 14:05:37 EEST 2012


At http://bazaar.launchpad.net/~maria-captains/maria/5.5

------------------------------------------------------------
revno: 3461
revision-id: knielsen at knielsen-hq.org-20120905110537-fr8u6iofs3h0igqa
parent: knielsen at knielsen-hq.org-20120904100634-yfwzz7o9ksha5c3s
committer: knielsen at knielsen-hq.org
branch nick: work-5.5-mdev225-181-232-rebased
timestamp: Wed 2012-09-05 13:05:37 +0200
message:
  MDEV-232: Fix uninitialised variable reference when --binlog-optimize-thread-scheduling=0
  
  The handling of checkpoint_and_purge() in this case was completely wrong.
=== modified file 'sql/log.cc'
--- a/sql/log.cc	2012-09-04 10:06:34 +0000
+++ b/sql/log.cc	2012-09-05 11:05:37 +0000
@@ -6216,9 +6216,6 @@ MYSQL_BIN_LOG::write_transaction_to_binl
 bool
 MYSQL_BIN_LOG::write_transaction_to_binlog_events(group_commit_entry *entry)
 {
-  bool check_purge;
-  ulong binlog_id;
-
   /*
     To facilitate group commit for the binlog, we first queue up ourselves in
     the group commit queue. Then the first thread to enter the queue waits for
@@ -6249,7 +6246,7 @@ MYSQL_BIN_LOG::write_transaction_to_binl
   if (orig_queue != NULL)
     entry->thd->wait_for_wakeup_ready();
   else
-    trx_group_commit_leader(entry, &check_purge, &binlog_id);
+    trx_group_commit_leader(entry);
 
   if (!opt_optimize_thread_scheduling)
   {
@@ -6283,8 +6280,8 @@ MYSQL_BIN_LOG::write_transaction_to_binl
         must do the commit checkpoint and log purge here, after all
         commit_ordered() calls have finished, and locks have been released.
       */
-      if (check_purge)
-        checkpoint_and_purge(binlog_id);
+      if (entry->check_purge)
+        checkpoint_and_purge(entry->binlog_id);
     }
 
   }
@@ -6335,13 +6332,11 @@ MYSQL_BIN_LOG::write_transaction_to_binl
 
  */
 void
-MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader,
-                                       bool *check_purge_ptr,
-                                       ulong *binlog_id_ptr)
+MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
 {
   uint xid_count= 0;
   my_off_t UNINIT_VAR(commit_offset);
-  group_commit_entry *current;
+  group_commit_entry *current, *last_in_queue;
   group_commit_entry *queue= NULL;
   bool check_purge= false;
   ulong binlog_id;
@@ -6365,6 +6360,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(g
     mysql_mutex_unlock(&LOCK_prepare_ordered);
 
     /* As the queue is in reverse order of entering, reverse it. */
+    last_in_queue= current;
     while (current)
     {
       group_commit_entry *next= current->next;
@@ -6523,13 +6519,13 @@ MYSQL_BIN_LOG::trx_group_commit_leader(g
     group_commit_queue_busy= TRUE;
 
     /*
-      Return these so parent can run checkpoint_and_purge().
+      Set these so parent can run checkpoint_and_purge() in last thread.
       (When using optimized thread scheduling, we run checkpoint_and_purge()
-      in this function, so parent does not need to and we need not return
-      these values).
+      in this function, so parent does not need to and we need not set these
+      values).
     */
-    *check_purge_ptr= check_purge;
-    *binlog_id_ptr= binlog_id;
+    last_in_queue->check_purge= check_purge;
+    last_in_queue->binlog_id= binlog_id;
 
     /* Note that we return with LOCK_commit_ordered locked! */
     DBUG_VOID_RETURN;

=== modified file 'sql/log.h'
--- a/sql/log.h	2012-09-04 10:06:34 +0000
+++ b/sql/log.h	2012-09-05 11:05:37 +0000
@@ -442,6 +442,12 @@ class MYSQL_BIN_LOG: public TC_LOG, priv
       method).
     */
     bool need_unlog;
+    /*
+      Fields used to pass the necessary information to the last thread in a
+      group commit, only used when opt_optimize_thread_scheduling is not set.
+    */
+    bool check_purge;
+    ulong binlog_id;
   };
 
   /*
@@ -546,8 +552,7 @@ class MYSQL_BIN_LOG: public TC_LOG, priv
   void purge();
   int write_transaction_or_stmt(group_commit_entry *entry);
   bool write_transaction_to_binlog_events(group_commit_entry *entry);
-  void trx_group_commit_leader(group_commit_entry *leader,
-                               bool *check_purge_ptr, ulong *binlog_id_ptr);
+  void trx_group_commit_leader(group_commit_entry *leader);
   void mark_xid_done(ulong cookie, bool write_checkpoint);
   void mark_xids_active(ulong cookie, uint xid_count);
 



More information about the commits mailing list