1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-08-05 04:01:12 +03:00

Extract before_commit_local()

This commit is contained in:
Teemu Ollakka
2023-04-04 08:43:35 +03:00
parent 5185ad3481
commit 908e4bc192
2 changed files with 75 additions and 75 deletions

View File

@@ -245,6 +245,7 @@ namespace wsrep
// error status accordingly. // error status accordingly.
bool abort_or_interrupt(wsrep::unique_lock<wsrep::mutex>&); bool abort_or_interrupt(wsrep::unique_lock<wsrep::mutex>&);
int streaming_step(wsrep::unique_lock<wsrep::mutex>&, bool force = false); int streaming_step(wsrep::unique_lock<wsrep::mutex>&, bool force = false);
int before_commit_local(wsrep::unique_lock<wsrep::mutex>&);
int certify_fragment(wsrep::unique_lock<wsrep::mutex>&); int certify_fragment(wsrep::unique_lock<wsrep::mutex>&);
int certify_commit(wsrep::unique_lock<wsrep::mutex>&); int certify_commit(wsrep::unique_lock<wsrep::mutex>&);
int append_sr_keys_for_commit(); int append_sr_keys_for_commit();

View File

@@ -438,40 +438,26 @@ int wsrep::transaction::after_prepare(
return ret; return ret;
} }
int wsrep::transaction::before_commit() int wsrep::transaction::before_commit_local(
wsrep::unique_lock<wsrep::mutex>& lock)
{ {
int ret(1); int ret = 1;
assert(state() == s_executing || state() == s_prepared
|| state() == s_committing || state() == s_must_abort
|| state() == s_replaying);
assert((state() != s_committing && state() != s_replaying) || certified());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("before_commit_enter");
assert(client_state_.mode() != wsrep::client_state::m_toi);
assert(state() == s_executing ||
state() == s_prepared ||
state() == s_committing ||
state() == s_must_abort ||
state() == s_replaying);
assert((state() != s_committing && state() != s_replaying) ||
certified());
switch (client_state_.mode())
{
case wsrep::client_state::m_local:
if (state() == s_executing) if (state() == s_executing)
{ {
ret = before_prepare(lock) || after_prepare(lock); ret = before_prepare(lock) || after_prepare(lock);
assert((ret == 0 && assert((ret == 0 && (state() == s_committing || state() == s_prepared))
(state() == s_committing || state() == s_prepared)) || (state() == s_must_abort || state() == s_must_replay
|| || state() == s_cert_failed || state() == s_aborted));
(state() == s_must_abort ||
state() == s_must_replay ||
state() == s_cert_failed ||
state() == s_aborted));
} }
else if (state() != s_committing && state() != s_prepared) else if (state() != s_committing && state() != s_prepared)
{ {
assert(state() == s_must_abort); assert(state() == s_must_abort);
if (certified() || if (certified() || (is_xa() && is_streaming()))
(is_xa() && is_streaming()))
{ {
state(lock, s_must_replay); state(lock, s_must_replay);
} }
@@ -489,11 +475,9 @@ int wsrep::transaction::before_commit()
if (ret == 0 && state() == s_prepared) if (ret == 0 && state() == s_prepared)
{ {
ret = certify_commit(lock); ret = certify_commit(lock);
assert((ret == 0 && state() == s_committing) || assert((ret == 0 && state() == s_committing)
(state() == s_must_abort || || (state() == s_must_abort || state() == s_must_replay
state() == s_must_replay || || state() == s_cert_failed || state() == s_prepared));
state() == s_cert_failed ||
state() == s_prepared));
} }
if (ret == 0) if (ret == 0)
@@ -502,13 +486,12 @@ int wsrep::transaction::before_commit()
assert(ordered()); assert(ordered());
lock.unlock(); lock.unlock();
client_service_.debug_sync("wsrep_before_commit_order_enter"); client_service_.debug_sync("wsrep_before_commit_order_enter");
enum wsrep::provider::status enum wsrep::provider::status status(
status(provider().commit_order_enter(ws_handle_, ws_meta_)); provider().commit_order_enter(ws_handle_, ws_meta_));
lock.lock(); lock.lock();
switch (status) switch (status)
{ {
case wsrep::provider::success: case wsrep::provider::success: break;
break;
case wsrep::provider::error_bf_abort: case wsrep::provider::error_bf_abort:
if (state() != s_must_abort) if (state() != s_must_abort)
{ {
@@ -523,7 +506,23 @@ int wsrep::transaction::before_commit()
break; break;
} }
} }
break; return ret;
}
int wsrep::transaction::before_commit()
{
int ret(1);
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("before_commit_enter");
assert(client_state_.mode() != wsrep::client_state::m_toi);
switch (client_state_.mode())
{
case wsrep::client_state::m_local:
return before_commit_local(lock);
case wsrep::client_state::m_high_priority: case wsrep::client_state::m_high_priority:
assert(certified()); assert(certified());
assert(ordered()); assert(ordered());