Bug #70597 crash_commit_before_unlog not called at proper location
Submitted: 10 Oct 2013 22:12 Modified: 11 Oct 2013 15:57
Reporter: Inaam Rana (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: XA transactions Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: CPU Architecture:Any

[10 Oct 2013 22:12] Inaam Rana
Description:
The code around 2PC changed significantly in 5.6 due to group commit. One of the DBUG_EXECUTE_IF() point 'crash_commit_before_unlog' in 5.5 was called after storage engine is has committed and before number of prepared Xids in the server is decremented. In 5.6 this is moved to a location just before binlog rotate which is not what we want.

How to repeat:
see code

Suggested fix:
diff --git a/sql/binlog.cc b/sql/binlog.cc
index 311894c..a53a6f9 100644
--- a/sql/binlog.cc
+++ b/sql/binlog.cc
@@ -6374,6 +6374,7 @@ MYSQL_BIN_LOG::process_commit_stage_queue(THD *thd, THD *first)
       among user thread, rotate thread and dump thread.
     */
     if (head->transaction.flags.xid_written)
+      DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE(););
       dec_prep_xids(head);
   }
 }
@@ -6790,7 +6791,6 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
       need the mutex. Otherwise causes various deadlocks.
     */
 
-    DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE(););
     DEBUG_SYNC(thd, "ready_to_do_rotation");
     bool check_purge= false;
     mysql_mutex_lock(&LOCK_log);
[11 Oct 2013 2:34] Davi Arnaut
The patch changes the behavior of calling dec_prep_xids, should be inside braces.
[11 Oct 2013 15:37] Laurynas Biveinis
See bug 68929
[11 Oct 2013 15:57] Inaam Rana
Davi, my bad on braces!
Laurynas, Thanks for pointing the duplicate out.

I am closing this as duplicate of bug 68929