summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2016-08-25 15:39:39 -0400
committerNirbhay Choubey <nirbhay@mariadb.com>2016-08-25 15:39:39 -0400
commit90266e8a0eb46867c990930fa4d305d2424929ba (patch)
tree787918cf537c678ab4f7a949520c847fa3fd8442 /sql/lock.cc
parentdfa3046db48d8439cf3eb02ba6623fe2f6e44f91 (diff)
parentb506d9527b4303b91f69fe6b6f21f911e5bfef72 (diff)
downloadmariadb-git-90266e8a0eb46867c990930fa4d305d2424929ba.tar.gz
Merge branch '10.0-galera' into bb-10.1-serg
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 2e44786d6fe..47db9ec6bfa 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1036,10 +1036,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 */
}
@@ -1079,14 +1090,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 */
@@ -1100,7 +1108,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)