1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

poll_enter_toi timeout handlign

This commit is contained in:
Leandro Pacheco
2019-09-13 18:52:17 -03:00
committed by Teemu Ollakka
parent 64fda07e91
commit f27f549479
2 changed files with 32 additions and 11 deletions

View File

@ -1025,7 +1025,8 @@ namespace wsrep
const wsrep::const_buffer& buffer,
wsrep::ws_meta& meta,
int flags,
std::chrono::time_point<wsrep::clock> wait_until);
std::chrono::time_point<wsrep::clock> wait_until,
bool& timed_out);
void enter_toi_common(wsrep::unique_lock<wsrep::mutex>&);
void leave_toi_common();

View File

@ -339,7 +339,8 @@ wsrep::client_state::poll_enter_toi(
const wsrep::const_buffer& buffer,
wsrep::ws_meta& meta,
int flags,
std::chrono::time_point<wsrep::clock> wait_until)
std::chrono::time_point<wsrep::clock> wait_until,
bool& timed_out)
{
WSREP_LOG_DEBUG(debug_log_level(),
wsrep::log::debug_level_client_state,
@ -348,6 +349,7 @@ wsrep::client_state::poll_enter_toi(
<< ","
<< wait_until.time_since_epoch().count());
enum wsrep::provider::status status;
timed_out = false;
do
{
lock.unlock();
@ -372,13 +374,13 @@ wsrep::client_state::poll_enter_toi(
::usleep(100000);
}
lock.lock();
timed_out = !(wait_until.time_since_epoch().count() &&
wsrep::clock::now() < wait_until);
}
while ((status == wsrep::provider::error_certification_failed ||
status == wsrep::provider::error_connection_failed) &&
wait_until.time_since_epoch().count() &&
wsrep::clock::now() < wait_until &&
not timed_out &&
not client_service_.interrupted(lock));
/** @todo should report timeout error if wait times out */
return status;
}
@ -401,12 +403,14 @@ int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
bool timed_out;
auto const status(poll_enter_toi(
lock, keys, buffer,
toi_meta_,
wsrep::provider::flag::start_transaction |
wsrep::provider::flag::commit,
wait_until));
wait_until,
timed_out));
switch (status)
{
case wsrep::provider::success:
@ -420,7 +424,11 @@ int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
ret = 1;
break;
default:
override_error(e_error_during_commit, status);
if (timed_out) {
override_error(e_timeout_error);
} else {
override_error(e_error_during_commit, status);
}
ret = 1;
break;
}
@ -541,11 +549,13 @@ int wsrep::client_state::begin_nbo_phase_one(
assert(toi_mode_ == m_undefined);
int ret;
bool timed_out;
auto const status(poll_enter_toi(
lock, keys, buffer,
toi_meta_,
wsrep::provider::flag::start_transaction,
wait_until));
wait_until,
timed_out));
switch (status)
{
case wsrep::provider::success:
@ -558,7 +568,11 @@ int wsrep::client_state::begin_nbo_phase_one(
ret = 1;
break;
default:
override_error(e_error_during_commit, status);
if (timed_out) {
override_error(e_timeout_error);
} else {
override_error(e_error_during_commit, status);
}
ret = 1;
break;
}
@ -627,12 +641,14 @@ int wsrep::client_state::begin_nbo_phase_two(
// an input param containing gtid of NBO begin.
// Output stored in nbo_meta_ is copied to toi_meta_ for
// phase two end.
bool timed_out;
enum wsrep::provider::status status(
poll_enter_toi(lock, keys,
wsrep::const_buffer(),
nbo_meta_,
wsrep::provider::flag::commit,
wait_until));
wait_until,
timed_out));
int ret;
switch (status)
{
@ -642,7 +658,11 @@ int wsrep::client_state::begin_nbo_phase_two(
toi_mode_ = m_local;
break;
default:
override_error(e_error_during_commit, status);
if (timed_out) {
override_error(e_timeout_error);
} else {
override_error(e_error_during_commit, status);
}
// Failed to grab TOI for completing NBO in order. This means that
// the operation cannot be ended in total order, so we end the
// NBO mode and let the DBMS to deal with the error.