summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-09-09 08:33:08 +0200
committerSergei Golubchik <serg@mariadb.org>2016-09-09 08:33:08 +0200
commit06b7fce9f24116080168b924d17f71b979fc3a14 (patch)
tree5ff9f5684bb118abbee5a9fd3b838d0841661287 /sql/lock.cc
parent1f2ff25eba6c089b2698cd0dab96155ccbf2afd2 (diff)
parent8494039757a2f6353cc161e7824aab4fe2312d2a (diff)
downloadmariadb-git-06b7fce9f24116080168b924d17f71b979fc3a14.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc58
1 files changed, 51 insertions, 7 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 07286324fc5..8aebc1f30d9 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1073,10 +1073,21 @@ void Global_read_lock::unlock_global_read_lock(THD *thd)
thd->mdl_context.release_lock(m_mdl_blocks_commits_lock);
m_mdl_blocks_commits_lock= NULL;
#ifdef WITH_WSREP
- if (WSREP_ON)
+ if (WSREP(thd) || wsrep_node_is_donor())
{
wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED;
wsrep->resume(wsrep);
+ /* resync here only if we did implicit desync earlier */
+ if (!wsrep_desync && wsrep_node_is_synced())
+ {
+ 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 */
}
@@ -1116,14 +1127,11 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
DBUG_RETURN(0);
#ifdef WITH_WSREP
- if (WSREP_ON && 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");
- thd->mdl_context.release_lock(m_mdl_blocks_commits_lock);
- m_mdl_blocks_commits_lock= NULL;
- wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED;
- wsrep->resume(wsrep);
+ DBUG_RETURN(FALSE);
}
#endif /* WITH_WSREP */
@@ -1137,7 +1145,43 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT;
#ifdef WITH_WSREP
- if (WSREP_ON)
+ /* 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) && !wsrep_node_is_donor())
+ {
+ DBUG_RETURN(FALSE);
+ }
+
+ /* if already desynced or donor, avoid double desyncing
+ if not in PC and synced, desyncing is not possible either
+ */
+ if (wsrep_desync || !wsrep_node_is_synced())
+ {
+ 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)
+ {
+ wsrep_locked_seqno= ret;
+ }
+ else if (ret != -ENOSYS) /* -ENOSYS - no provider */
{
long long ret = wsrep->pause(wsrep);
if (ret >= 0)