[Commits] 076f86e: Follow-up patch for more aggressive retry in --slave-parallel-mode=aggressive

Kristian Nielsen knielsen at knielsen-hq.org
Fri Jul 3 07:01:44 EEST 2015


revision-id: 076f86ec81cf672d5692fb2fe449076ae848db91
parent(s): 9c65f0ab0a6418dbaaf0c6a5ae29bb388645946d
committer: Kristian Nielsen
branch nick: mariadb
timestamp: 2015-07-03 05:59:37 +0200
message:

Follow-up patch for more aggressive retry in --slave-parallel-mode=aggressive

Now after having retried a transaction slave_trans_retries/2 times, we
fall back to waiting for all prior transactions to commit before
continuing to retry.

This way, we avoid breaking replication if we repeatedly deadlock
against a list of earlier transactions T1, T2, T3, ...

---
 sql/rpl_parallel.cc | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 3ea2b6b..0045de0 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -349,6 +349,7 @@ retry_event_group(rpl_group_info *rgi, rpl_parallel_thread *rpt,
   ulong retries= 0;
   Format_description_log_event *description_event= NULL;
   ulonglong *prev_phase;
+  bool need_reregister;
 
   prev_phase= thd->update_slave_time_status(&slave_parallel_trx_retry);
 
@@ -432,25 +433,34 @@ retry_event_group(rpl_group_info *rgi, rpl_parallel_thread *rpt,
       multiple deadlock kills against multiple prior transactions (since we
       already conflicted with one transaction, there might be increased risk
       of more conflicts).
+
+      In aggressive mode we fall back to waiting for all prior transactions if
+      we reach slave_trans_retries/2, to avoid excessive retries causing
+      replication to fail.
     */
     mysql_mutex_lock(&thd->LOCK_thd_data);
     deadlock_sub_id= rgi->deadlock_kill_wait_commit_sub_id;
     deadlock_wfc= rgi->deadlock_kill_wfc;
+    rgi->deadlock_kill_wfc= NULL;
     mysql_mutex_unlock(&thd->LOCK_thd_data);
     mysql_mutex_lock(&entry->LOCK_parallel_entry);
-    if (deadlock_wfc && rli->mi->parallel_mode >= SLAVE_PARALLEL_AGGRESSIVE)
+    if (deadlock_wfc && rli->mi->parallel_mode >= SLAVE_PARALLEL_AGGRESSIVE &&
+        retries < slave_trans_retries/2)
     {
       if (deadlock_sub_id > entry->last_committed_sub_id)
-        rgi->commit_orderer.register_wait_for_prior_commit(rgi->deadlock_kill_wfc);
+        rgi->commit_orderer.register_wait_for_prior_commit(deadlock_wfc);
+      need_reregister= true;
     }
     else
+    {
       register_wait_for_prior_event_group_commit(rgi, entry);
+      need_reregister= false;
+    }
     mysql_mutex_unlock(&entry->LOCK_parallel_entry);
-    rgi->deadlock_kill_wfc= NULL;
 
     if (!(err= thd->wait_for_prior_commit()))
     {
-      if (deadlock_wfc && rli->mi->parallel_mode >= SLAVE_PARALLEL_AGGRESSIVE)
+      if (need_reregister)
       {
         /*
           If we waited for an earlier transaction before retrying, now we have


More information about the commits mailing list