mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
Remove duplicate logic from after_statement
Remove bf abort handling `client_state::after_statement()`, since the same logic already appears later in `transaction::after_statement()`. Also, introduce `transaction::after_statement()` overload which takes a lock.
This commit is contained in:
@ -192,6 +192,7 @@ namespace wsrep
|
|||||||
int before_statement();
|
int before_statement();
|
||||||
|
|
||||||
int after_statement();
|
int after_statement();
|
||||||
|
int after_statement(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
|
|
||||||
void after_command_must_abort(wsrep::unique_lock<wsrep::mutex>&);
|
void after_command_must_abort(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
|
|
||||||
|
@ -168,9 +168,7 @@ int wsrep::client_state::before_command(bool keep_command_error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up the transaction and return error.
|
// Clean up the transaction and return error.
|
||||||
lock.unlock();
|
(void)transaction_.after_statement(lock);
|
||||||
(void)transaction_.after_statement();
|
|
||||||
lock.lock();
|
|
||||||
|
|
||||||
assert(transaction_.active() == false);
|
assert(transaction_.active() == false);
|
||||||
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
||||||
@ -199,9 +197,7 @@ void wsrep::client_state::after_command_before_result()
|
|||||||
// hook.
|
// hook.
|
||||||
if (not keep_command_error_)
|
if (not keep_command_error_)
|
||||||
{
|
{
|
||||||
lock.unlock();
|
(void)transaction_.after_statement(lock);
|
||||||
(void)transaction_.after_statement();
|
|
||||||
lock.lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
||||||
@ -266,37 +262,18 @@ int wsrep::client_state::after_statement()
|
|||||||
debug_log_state("after_statement: enter");
|
debug_log_state("after_statement: enter");
|
||||||
assert(state() == s_exec);
|
assert(state() == s_exec);
|
||||||
assert(mode() == m_local);
|
assert(mode() == m_local);
|
||||||
|
(void)transaction_.after_statement(lock);
|
||||||
if (transaction_.active() &&
|
|
||||||
transaction_.state() == wsrep::transaction::s_must_abort)
|
|
||||||
{
|
|
||||||
lock.unlock();
|
|
||||||
client_service_.bf_rollback();
|
|
||||||
lock.lock();
|
|
||||||
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
|
||||||
// Error may be set already. For example, if fragment size
|
|
||||||
// exceeded the maximum size in certify_fragment(), then
|
|
||||||
// we already have wsrep::e_error_during_commit
|
|
||||||
if (current_error() == wsrep::e_success)
|
|
||||||
{
|
|
||||||
override_error(wsrep::e_deadlock_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
(void)transaction_.after_statement();
|
|
||||||
if (current_error() == wsrep::e_deadlock_error)
|
if (current_error() == wsrep::e_deadlock_error)
|
||||||
{
|
{
|
||||||
if (mode_ == m_local)
|
if (mode_ == m_local)
|
||||||
{
|
{
|
||||||
debug_log_state("after_statement: may_retry");
|
debug_log_state("after_statement: may_retry");
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_log_state("after_statement: error");
|
debug_log_state("after_statement: error");
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
debug_log_state("after_statement: success");
|
debug_log_state("after_statement: success");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -815,10 +815,16 @@ void wsrep::transaction::remove_fragments_in_storage_service_scope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int wsrep::transaction::after_statement()
|
int wsrep::transaction::after_statement()
|
||||||
|
{
|
||||||
|
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||||
|
return after_statement(lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wsrep::transaction::after_statement(wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
|
||||||
debug_log_state("after_statement_enter");
|
debug_log_state("after_statement_enter");
|
||||||
|
assert(lock.owns_lock());
|
||||||
assert(client_state_.mode() == wsrep::client_state::m_local);
|
assert(client_state_.mode() == wsrep::client_state::m_local);
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_prepared ||
|
state() == s_prepared ||
|
||||||
|
Reference in New Issue
Block a user