mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-31 18:24:25 +03:00
Extract before_commit_high_priority()
This commit is contained in:
@ -238,6 +238,8 @@ namespace wsrep
|
|||||||
|
|
||||||
wsrep::provider& provider();
|
wsrep::provider& provider();
|
||||||
void flags(int flags) { flags_ = flags; }
|
void flags(int flags) { flags_ = flags; }
|
||||||
|
int before_commit_local(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
|
int before_commit_high_priority(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
// Return true if the transaction must abort, is aborting,
|
// Return true if the transaction must abort, is aborting,
|
||||||
// or has been aborted, or has been interrupted by DBMS
|
// or has been aborted, or has been interrupted by DBMS
|
||||||
// as indicated by client_service::interrupted() call.
|
// as indicated by client_service::interrupted() call.
|
||||||
@ -245,7 +247,6 @@ 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();
|
||||||
|
@ -509,6 +509,37 @@ int wsrep::transaction::before_commit_local(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsrep::transaction::before_commit_high_priority(
|
||||||
|
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
assert(certified());
|
||||||
|
assert(ordered());
|
||||||
|
if (is_xa())
|
||||||
|
{
|
||||||
|
assert(state() == s_prepared || state() == s_replaying);
|
||||||
|
state(lock, s_committing);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else if (state() == s_executing || state() == s_replaying)
|
||||||
|
{
|
||||||
|
ret = before_prepare(lock) || after_prepare(lock);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
ret = ret || provider().commit_order_enter(ws_handle_, ws_meta_);
|
||||||
|
lock.lock();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
state(lock, s_must_abort);
|
||||||
|
state(lock, s_aborting);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int wsrep::transaction::before_commit()
|
int wsrep::transaction::before_commit()
|
||||||
{
|
{
|
||||||
int ret(1);
|
int ret(1);
|
||||||
@ -516,39 +547,13 @@ int wsrep::transaction::before_commit()
|
|||||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||||
debug_log_state("before_commit_enter");
|
debug_log_state("before_commit_enter");
|
||||||
assert(client_state_.mode() != wsrep::client_state::m_toi);
|
assert(client_state_.mode() != wsrep::client_state::m_toi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (client_state_.mode())
|
switch (client_state_.mode())
|
||||||
{
|
{
|
||||||
case wsrep::client_state::m_local:
|
case wsrep::client_state::m_local:
|
||||||
return before_commit_local(lock);
|
ret = before_commit_local(lock);
|
||||||
|
break;
|
||||||
case wsrep::client_state::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
assert(certified());
|
ret = before_commit_high_priority(lock);
|
||||||
assert(ordered());
|
|
||||||
if (is_xa())
|
|
||||||
{
|
|
||||||
assert(state() == s_prepared ||
|
|
||||||
state() == s_replaying);
|
|
||||||
state(lock, s_committing);
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
else if (state() == s_executing || state() == s_replaying)
|
|
||||||
{
|
|
||||||
ret = before_prepare(lock) || after_prepare(lock);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
lock.unlock();
|
|
||||||
ret = ret || provider().commit_order_enter(ws_handle_, ws_meta_);
|
|
||||||
lock.lock();
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
state(lock, s_must_abort);
|
|
||||||
state(lock, s_aborting);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
Reference in New Issue
Block a user