mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Split client_context::after_command() into two stages, before
sending result to client and after the result was sent. Added s_result state to client_context states.
This commit is contained in:
@ -40,9 +40,10 @@ int trrep::client_context::before_command()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void trrep::client_context::after_command()
|
||||
void trrep::client_context::after_command_before_result()
|
||||
{
|
||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
||||
assert(state() == s_exec);
|
||||
if (transaction_.active() &&
|
||||
transaction_.state() == trrep::transaction_context::s_must_abort)
|
||||
{
|
||||
@ -54,6 +55,26 @@ void trrep::client_context::after_command()
|
||||
assert(transaction_.state() == trrep::transaction_context::s_aborted);
|
||||
assert(current_error() != trrep::e_success);
|
||||
}
|
||||
state(lock, s_result);
|
||||
}
|
||||
|
||||
void trrep::client_context::after_command_after_result()
|
||||
{
|
||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
||||
assert(state() == s_result);
|
||||
if (transaction_.active() &&
|
||||
transaction_.state() == trrep::transaction_context::s_must_abort)
|
||||
{
|
||||
// Note: Error is not overridden here as the result has already
|
||||
// been sent to client. The error should be set in before_command()
|
||||
// when the client issues next command.
|
||||
lock.unlock();
|
||||
rollback();
|
||||
transaction_.after_statement();
|
||||
lock.lock();
|
||||
assert(transaction_.state() == trrep::transaction_context::s_aborted);
|
||||
assert(current_error() != trrep::e_success);
|
||||
}
|
||||
state(lock, s_idle);
|
||||
}
|
||||
|
||||
@ -103,10 +124,11 @@ void trrep::client_context::state(
|
||||
assert(lock.owns_lock());
|
||||
static const char allowed[state_max_][state_max_] =
|
||||
{
|
||||
/* idle exec quit */
|
||||
{ 0, 1, 1}, /* idle */
|
||||
{ 1, 0, 1}, /* exec */
|
||||
{ 0, 0, 0}
|
||||
/* idle exec result quit */
|
||||
{ 0, 1, 0, 1}, /* idle */
|
||||
{ 0, 0, 1, 0}, /* exec */
|
||||
{ 1, 0, 0, 1}, /* result */
|
||||
{ 0, 0, 0, 0} /* quit */
|
||||
};
|
||||
if (allowed[state_][state])
|
||||
{
|
||||
|
@ -25,5 +25,6 @@ BOOST_AUTO_TEST_CASE(client_context_test_error_codes)
|
||||
trrep_mock::bf_abort_unordered(cc);
|
||||
|
||||
cc.after_statement();
|
||||
cc.after_command();
|
||||
cc.after_command_before_result();
|
||||
cc.after_command_after_result();
|
||||
}
|
||||
|
@ -392,7 +392,8 @@ private:
|
||||
}
|
||||
after_statement();
|
||||
}
|
||||
after_command();
|
||||
after_command_before_result();
|
||||
after_command_after_result();
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,8 @@ int trrep::server_context::on_apply(
|
||||
if (not_replaying)
|
||||
{
|
||||
client_context.after_statement();
|
||||
client_context.after_command();
|
||||
client_context.after_command_before_result();
|
||||
client_context.after_command_after_result();
|
||||
}
|
||||
assert(ret ||
|
||||
txc.state() == trrep::transaction_context::s_committed);
|
||||
|
Reference in New Issue
Block a user