diff options
-rw-r--r-- | sql/lock.cc | 41 | ||||
-rw-r--r-- | sql/sql_class.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/wsrep_sst.cc | 1 |
4 files changed, 44 insertions, 2 deletions
diff --git a/sql/lock.cc b/sql/lock.cc index 07ea0b1f6dc..f724606a46d 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1071,6 +1071,16 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) #ifdef WITH_WSREP wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; wsrep->resume(wsrep); + if (!wsrep_desync && !thd->wsrep_donor) + { + int ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + DBUG_VOID_RETURN; + } + } #endif /* WITH_WSREP */ } thd->mdl_context.release_lock(m_mdl_global_shared_lock); @@ -1106,7 +1116,7 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) */ #ifdef WITH_WSREP - if (m_mdl_blocks_commits_lock) + if (WSREP(thd) && m_mdl_blocks_commits_lock) { WSREP_DEBUG("GRL was in block commit mode when entering " "make_global_read_lock_block_commit"); @@ -1131,6 +1141,35 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT; #ifdef WITH_WSREP + /* Native threads should bail out before wsrep oprations to follow. + Donor servicing thread is an exception, it should pause provider but not desync, + as it is already desynced in donor state + */ + if (!WSREP(thd) && !thd->wsrep_donor) + { + DBUG_RETURN(FALSE); + } + + /* if already desynced or donor, avoid double desyncing */ + if (wsrep_desync || thd->wsrep_donor) + { + WSREP_DEBUG("desync set upfont, skipping implicit desync for FTWRL: %d", + wsrep_desync); + } + else + { + int rcode; + WSREP_DEBUG("running implicit desync for node"); + rcode = wsrep->desync(wsrep); + if (rcode != WSREP_OK) + { + WSREP_WARN("FTWRL desync failed %d for schema: %s, query: %s", + rcode, (thd->db ? thd->db : "(null)"), thd->query()); + my_message(ER_LOCK_DEADLOCK, "wsrep desync failed for FTWRL", MYF(0)); + DBUG_RETURN(TRUE); + } + } + long long ret = wsrep->pause(wsrep); if (ret >= 0) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4873586aba5..6495069971b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1088,7 +1088,8 @@ THD::THD() wsrep_po_in_trans(FALSE), wsrep_apply_format(0), wsrep_apply_toi(false), - wsrep_skip_append_keys(false) + wsrep_skip_append_keys(false), + wsrep_donor(false) #endif { ulong tmp; diff --git a/sql/sql_class.h b/sql/sql_class.h index ee637b3726d..6181333e1b2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3880,6 +3880,7 @@ public: bool wsrep_apply_toi; /* applier processing in TOI */ bool wsrep_skip_append_keys; wsrep_gtid_t wsrep_sync_wait_gtid; + my_bool wsrep_donor; /* true if thread is SST donor servicing */ ulong wsrep_affected_rows; #endif /* WITH_WSREP */ }; diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index b697a557476..d13148b3d48 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -979,6 +979,7 @@ static void* sst_donor_thread (void* a) wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can // operate with wsrep_ready == OFF + thd.ptr->wsrep_donor = true; wsp::process proc(arg->cmd, "r", arg->env); err= proc.error(); |