mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
poll_enter_toi timeout handlign
This commit is contained in:
committed by
Teemu Ollakka
parent
64fda07e91
commit
f27f549479
@ -1025,7 +1025,8 @@ namespace wsrep
|
|||||||
const wsrep::const_buffer& buffer,
|
const wsrep::const_buffer& buffer,
|
||||||
wsrep::ws_meta& meta,
|
wsrep::ws_meta& meta,
|
||||||
int flags,
|
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 enter_toi_common(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
void leave_toi_common();
|
void leave_toi_common();
|
||||||
|
|
||||||
|
@ -339,7 +339,8 @@ wsrep::client_state::poll_enter_toi(
|
|||||||
const wsrep::const_buffer& buffer,
|
const wsrep::const_buffer& buffer,
|
||||||
wsrep::ws_meta& meta,
|
wsrep::ws_meta& meta,
|
||||||
int flags,
|
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(debug_log_level(),
|
||||||
wsrep::log::debug_level_client_state,
|
wsrep::log::debug_level_client_state,
|
||||||
@ -348,6 +349,7 @@ wsrep::client_state::poll_enter_toi(
|
|||||||
<< ","
|
<< ","
|
||||||
<< wait_until.time_since_epoch().count());
|
<< wait_until.time_since_epoch().count());
|
||||||
enum wsrep::provider::status status;
|
enum wsrep::provider::status status;
|
||||||
|
timed_out = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -372,13 +374,13 @@ wsrep::client_state::poll_enter_toi(
|
|||||||
::usleep(100000);
|
::usleep(100000);
|
||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
timed_out = !(wait_until.time_since_epoch().count() &&
|
||||||
|
wsrep::clock::now() < wait_until);
|
||||||
}
|
}
|
||||||
while ((status == wsrep::provider::error_certification_failed ||
|
while ((status == wsrep::provider::error_certification_failed ||
|
||||||
status == wsrep::provider::error_connection_failed) &&
|
status == wsrep::provider::error_connection_failed) &&
|
||||||
wait_until.time_since_epoch().count() &&
|
not timed_out &&
|
||||||
wsrep::clock::now() < wait_until &&
|
|
||||||
not client_service_.interrupted(lock));
|
not client_service_.interrupted(lock));
|
||||||
/** @todo should report timeout error if wait times out */
|
|
||||||
return status;
|
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_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
|
|
||||||
|
bool timed_out;
|
||||||
auto const status(poll_enter_toi(
|
auto const status(poll_enter_toi(
|
||||||
lock, keys, buffer,
|
lock, keys, buffer,
|
||||||
toi_meta_,
|
toi_meta_,
|
||||||
wsrep::provider::flag::start_transaction |
|
wsrep::provider::flag::start_transaction |
|
||||||
wsrep::provider::flag::commit,
|
wsrep::provider::flag::commit,
|
||||||
wait_until));
|
wait_until,
|
||||||
|
timed_out));
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case wsrep::provider::success:
|
case wsrep::provider::success:
|
||||||
@ -420,7 +424,11 @@ int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (timed_out) {
|
||||||
|
override_error(e_timeout_error);
|
||||||
|
} else {
|
||||||
override_error(e_error_during_commit, status);
|
override_error(e_error_during_commit, status);
|
||||||
|
}
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -541,11 +549,13 @@ int wsrep::client_state::begin_nbo_phase_one(
|
|||||||
assert(toi_mode_ == m_undefined);
|
assert(toi_mode_ == m_undefined);
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
bool timed_out;
|
||||||
auto const status(poll_enter_toi(
|
auto const status(poll_enter_toi(
|
||||||
lock, keys, buffer,
|
lock, keys, buffer,
|
||||||
toi_meta_,
|
toi_meta_,
|
||||||
wsrep::provider::flag::start_transaction,
|
wsrep::provider::flag::start_transaction,
|
||||||
wait_until));
|
wait_until,
|
||||||
|
timed_out));
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case wsrep::provider::success:
|
case wsrep::provider::success:
|
||||||
@ -558,7 +568,11 @@ int wsrep::client_state::begin_nbo_phase_one(
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (timed_out) {
|
||||||
|
override_error(e_timeout_error);
|
||||||
|
} else {
|
||||||
override_error(e_error_during_commit, status);
|
override_error(e_error_during_commit, status);
|
||||||
|
}
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -627,12 +641,14 @@ int wsrep::client_state::begin_nbo_phase_two(
|
|||||||
// an input param containing gtid of NBO begin.
|
// an input param containing gtid of NBO begin.
|
||||||
// Output stored in nbo_meta_ is copied to toi_meta_ for
|
// Output stored in nbo_meta_ is copied to toi_meta_ for
|
||||||
// phase two end.
|
// phase two end.
|
||||||
|
bool timed_out;
|
||||||
enum wsrep::provider::status status(
|
enum wsrep::provider::status status(
|
||||||
poll_enter_toi(lock, keys,
|
poll_enter_toi(lock, keys,
|
||||||
wsrep::const_buffer(),
|
wsrep::const_buffer(),
|
||||||
nbo_meta_,
|
nbo_meta_,
|
||||||
wsrep::provider::flag::commit,
|
wsrep::provider::flag::commit,
|
||||||
wait_until));
|
wait_until,
|
||||||
|
timed_out));
|
||||||
int ret;
|
int ret;
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@ -642,7 +658,11 @@ int wsrep::client_state::begin_nbo_phase_two(
|
|||||||
toi_mode_ = m_local;
|
toi_mode_ = m_local;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (timed_out) {
|
||||||
|
override_error(e_timeout_error);
|
||||||
|
} else {
|
||||||
override_error(e_error_during_commit, status);
|
override_error(e_error_during_commit, status);
|
||||||
|
}
|
||||||
// Failed to grab TOI for completing NBO in order. This means that
|
// Failed to grab TOI for completing NBO in order. This means that
|
||||||
// the operation cannot be ended in total order, so we end the
|
// the operation cannot be ended in total order, so we end the
|
||||||
// NBO mode and let the DBMS to deal with the error.
|
// NBO mode and let the DBMS to deal with the error.
|
||||||
|
Reference in New Issue
Block a user