Commit 7ae685d0 authored by Teemu Ollakka's avatar Teemu Ollakka Committed by Jan Lindström

Fixed replaying bugs found with multimaster load

The replayer did not signal replaying waiters. Added
mysql_cond_broadcast() after replaying is over.

Assertion on client error failed after replay attempt failed due
to certification failure. At this point the transaction does not
go through client state, so the client error cannot be overridden.
Assign ER_LOCK_DEADLOCK to thd directly instead.

Use timed cond wait when waiting for replayers to finish and
check if the transaction has been BF aborted during the wait.
parent 48554fe2
...@@ -260,6 +260,7 @@ enum wsrep::provider::status Wsrep_client_service::replay() ...@@ -260,6 +260,7 @@ enum wsrep::provider::status Wsrep_client_service::replay()
replayer_service.replay_status(ret); replayer_service.replay_status(ret);
mysql_mutex_lock(&LOCK_wsrep_replaying); mysql_mutex_lock(&LOCK_wsrep_replaying);
--wsrep_replaying; --wsrep_replaying;
mysql_cond_broadcast(&COND_wsrep_replaying);
mysql_mutex_unlock(&LOCK_wsrep_replaying); mysql_mutex_unlock(&LOCK_wsrep_replaying);
return ret; return ret;
} }
...@@ -269,9 +270,15 @@ void Wsrep_client_service::wait_for_replayers(wsrep::unique_lock<wsrep::mutex>& ...@@ -269,9 +270,15 @@ void Wsrep_client_service::wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&
DBUG_ASSERT(m_thd == current_thd); DBUG_ASSERT(m_thd == current_thd);
lock.unlock(); lock.unlock();
mysql_mutex_lock(&LOCK_wsrep_replaying); mysql_mutex_lock(&LOCK_wsrep_replaying);
while (wsrep_replaying > 0) /* We need to check if the THD is BF aborted during condition wait.
Because the aborter does not know which condition this thread is waiting,
use timed wait and check if the THD is BF aborted in the loop. */
while (wsrep_replaying > 0 && !wsrep_is_bf_aborted(m_thd))
{ {
mysql_cond_wait(&COND_wsrep_replaying, &LOCK_wsrep_replaying); struct timespec wait_time;
set_timespec_nsec(wait_time, 10000000L);
mysql_cond_timedwait(&COND_wsrep_replaying, &LOCK_wsrep_replaying,
&wait_time);
} }
mysql_mutex_unlock(&LOCK_wsrep_replaying); mysql_mutex_unlock(&LOCK_wsrep_replaying);
lock.lock(); lock.lock();
......
...@@ -598,7 +598,7 @@ Wsrep_replayer_service::~Wsrep_replayer_service() ...@@ -598,7 +598,7 @@ Wsrep_replayer_service::~Wsrep_replayer_service()
} }
else if (m_replay_status == wsrep::provider::error_certification_failed) else if (m_replay_status == wsrep::provider::error_certification_failed)
{ {
DBUG_ASSERT(thd->wsrep_cs().current_error() == wsrep::e_deadlock_error); wsrep_override_error(thd, ER_LOCK_DEADLOCK);
} }
else else
{ {
......
Subproject commit 92024c7d502b716c8c0ca5e2b9524b43d3a5378c Subproject commit 0b09871ad5a10a773c4cbad28e681021d8d234b6
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment