mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-31 18:24:25 +03:00
Renamed transcation_context to transaction
This commit is contained in:
@ -8,6 +8,6 @@ add_library(wsrep-lib
|
||||
logger.cpp
|
||||
provider.cpp
|
||||
server_context.cpp
|
||||
transaction_context.cpp
|
||||
transaction.cpp
|
||||
wsrep_provider_v26.cpp)
|
||||
target_link_libraries(wsrep-lib wsrep_api_v26 pthread dl)
|
||||
|
@ -38,21 +38,21 @@ int wsrep::client_state::before_command()
|
||||
* @todo Wait until the possible synchronous rollback
|
||||
* has been finished.
|
||||
*/
|
||||
while (transaction_.state() == wsrep::transaction_context::s_aborting)
|
||||
while (transaction_.state() == wsrep::transaction::s_aborting)
|
||||
{
|
||||
// cond_.wait(lock);
|
||||
}
|
||||
}
|
||||
state(lock, s_exec);
|
||||
assert(transaction_.active() == false ||
|
||||
(transaction_.state() == wsrep::transaction_context::s_executing ||
|
||||
transaction_.state() == wsrep::transaction_context::s_aborted ||
|
||||
(transaction_.state() == wsrep::transaction_context::s_must_abort &&
|
||||
(transaction_.state() == wsrep::transaction::s_executing ||
|
||||
transaction_.state() == wsrep::transaction::s_aborted ||
|
||||
(transaction_.state() == wsrep::transaction::s_must_abort &&
|
||||
server_context_.rollback_mode() == wsrep::server_context::rm_async)));
|
||||
|
||||
if (transaction_.active())
|
||||
{
|
||||
if (transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||
if (transaction_.state() == wsrep::transaction::s_must_abort)
|
||||
{
|
||||
assert(server_context_.rollback_mode() ==
|
||||
wsrep::server_context::rm_async);
|
||||
@ -62,13 +62,13 @@ int wsrep::client_state::before_command()
|
||||
(void)transaction_.after_statement();
|
||||
lock.lock();
|
||||
assert(transaction_.state() ==
|
||||
wsrep::transaction_context::s_aborted);
|
||||
wsrep::transaction::s_aborted);
|
||||
assert(transaction_.active() == false);
|
||||
assert(current_error() != wsrep::e_success);
|
||||
debug_log_state("before_command: error");
|
||||
return 1;
|
||||
}
|
||||
else if (transaction_.state() == wsrep::transaction_context::s_aborted)
|
||||
else if (transaction_.state() == wsrep::transaction::s_aborted)
|
||||
{
|
||||
// Transaction was rolled back either just before sending result
|
||||
// to the client, or after client_state become idle.
|
||||
@ -92,14 +92,14 @@ void wsrep::client_state::after_command_before_result()
|
||||
debug_log_state("after_command_before_result: enter");
|
||||
assert(state() == s_exec);
|
||||
if (transaction_.active() &&
|
||||
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||
transaction_.state() == wsrep::transaction::s_must_abort)
|
||||
{
|
||||
override_error(wsrep::e_deadlock_error);
|
||||
lock.unlock();
|
||||
client_service_.rollback(*this);
|
||||
(void)transaction_.after_statement();
|
||||
lock.lock();
|
||||
assert(transaction_.state() == wsrep::transaction_context::s_aborted);
|
||||
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
||||
assert(current_error() != wsrep::e_success);
|
||||
}
|
||||
state(lock, s_result);
|
||||
@ -111,14 +111,14 @@ void wsrep::client_state::after_command_after_result()
|
||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||
debug_log_state("after_command_after_result_enter");
|
||||
assert(state() == s_result);
|
||||
assert(transaction_.state() != wsrep::transaction_context::s_aborting);
|
||||
assert(transaction_.state() != wsrep::transaction::s_aborting);
|
||||
if (transaction_.active() &&
|
||||
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||
transaction_.state() == wsrep::transaction::s_must_abort)
|
||||
{
|
||||
lock.unlock();
|
||||
client_service_.rollback(*this);
|
||||
lock.lock();
|
||||
assert(transaction_.state() == wsrep::transaction_context::s_aborted);
|
||||
assert(transaction_.state() == wsrep::transaction::s_aborted);
|
||||
override_error(wsrep::e_deadlock_error);
|
||||
}
|
||||
else if (transaction_.active() == false)
|
||||
@ -146,7 +146,7 @@ int wsrep::client_state::before_statement()
|
||||
#endif // 0
|
||||
|
||||
if (transaction_.active() &&
|
||||
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||
transaction_.state() == wsrep::transaction::s_must_abort)
|
||||
{
|
||||
// Rollback and cleanup will happen in after_command_before_result()
|
||||
debug_log_state("before_statement_error");
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "wsrep/server_context.hpp"
|
||||
#include "wsrep/client_state.hpp"
|
||||
#include "wsrep/transaction_context.hpp"
|
||||
#include "wsrep/transaction.hpp"
|
||||
#include "wsrep/view.hpp"
|
||||
#include "wsrep/logger.hpp"
|
||||
#include "wsrep/compiler.hpp"
|
||||
@ -124,11 +124,11 @@ int wsrep::server_context::on_apply(
|
||||
const wsrep::const_buffer& data)
|
||||
{
|
||||
int ret(0);
|
||||
const wsrep::transaction_context& txc(client_state.transaction());
|
||||
const wsrep::transaction& txc(client_state.transaction());
|
||||
assert(client_state.mode() == wsrep::client_state::m_high_priority);
|
||||
|
||||
bool not_replaying(txc.state() !=
|
||||
wsrep::transaction_context::s_replaying);
|
||||
wsrep::transaction::s_replaying);
|
||||
|
||||
if (starts_transaction(ws_meta.flags()) &&
|
||||
commits_transaction(ws_meta.flags()))
|
||||
@ -166,7 +166,7 @@ int wsrep::server_context::on_apply(
|
||||
client_state.after_command_after_result();
|
||||
}
|
||||
assert(ret ||
|
||||
txc.state() == wsrep::transaction_context::s_committed);
|
||||
txc.state() == wsrep::transaction::s_committed);
|
||||
}
|
||||
else if (starts_transaction(ws_meta.flags()))
|
||||
{
|
||||
@ -275,7 +275,7 @@ int wsrep::server_context::on_apply(
|
||||
|
||||
bool wsrep::server_context::statement_allowed_for_streaming(
|
||||
const wsrep::client_state&,
|
||||
const wsrep::transaction_context&) const
|
||||
const wsrep::transaction&) const
|
||||
{
|
||||
/* Streaming not implemented yet. */
|
||||
return false;
|
||||
|
@ -40,10 +40,10 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc,
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, ws_handle, ws_meta,
|
||||
wsrep::const_buffer(buf, 1)) == 0);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
const wsrep::transaction& txc(cc.transaction());
|
||||
// ::abort();
|
||||
BOOST_REQUIRE_MESSAGE(
|
||||
txc.state() == wsrep::transaction_context::s_committed,
|
||||
txc.state() == wsrep::transaction::s_committed,
|
||||
"Transaction state " << txc.state() << " not committed");
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc,
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, ws_handle, ws_meta,
|
||||
wsrep::const_buffer(buf, 1)) == 0);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_committed);
|
||||
const wsrep::transaction& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction::s_committed);
|
||||
}
|
||||
|
||||
// Test on_apply() method for 1pc transaction which
|
||||
@ -67,8 +67,8 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc_rollback,
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, ws_handle, ws_meta,
|
||||
wsrep::const_buffer(buf, 1)) == 1);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_aborted);
|
||||
const wsrep::transaction& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction::s_aborted);
|
||||
}
|
||||
|
||||
// Test on_apply() method for 2pc transaction which
|
||||
@ -80,6 +80,6 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc_rollback,
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, ws_handle, ws_meta,
|
||||
wsrep::const_buffer(buf, 1)) == 1);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_aborted);
|
||||
const wsrep::transaction& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction::s_aborted);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#include "wsrep/transaction_context.hpp"
|
||||
#include "wsrep/transaction.hpp"
|
||||
#include "wsrep/client_state.hpp"
|
||||
#include "wsrep/server_context.hpp"
|
||||
#include "wsrep/key.hpp"
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
// Public
|
||||
|
||||
wsrep::transaction_context::transaction_context(
|
||||
wsrep::transaction::transaction(
|
||||
wsrep::client_state& client_state)
|
||||
: provider_(client_state.provider())
|
||||
, client_state_(client_state)
|
||||
@ -39,11 +39,11 @@ wsrep::transaction_context::transaction_context(
|
||||
{ }
|
||||
|
||||
|
||||
wsrep::transaction_context::~transaction_context()
|
||||
wsrep::transaction::~transaction()
|
||||
{
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::start_transaction(
|
||||
int wsrep::transaction::start_transaction(
|
||||
const wsrep::transaction_id& id)
|
||||
{
|
||||
assert(active() == false);
|
||||
@ -65,7 +65,7 @@ int wsrep::transaction_context::start_transaction(
|
||||
}
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::start_transaction(
|
||||
int wsrep::transaction::start_transaction(
|
||||
const wsrep::ws_handle& ws_handle,
|
||||
const wsrep::ws_meta& ws_meta)
|
||||
{
|
||||
@ -81,7 +81,7 @@ int wsrep::transaction_context::start_transaction(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::start_replaying(const wsrep::ws_meta& ws_meta)
|
||||
int wsrep::transaction::start_replaying(const wsrep::ws_meta& ws_meta)
|
||||
{
|
||||
ws_meta_ = ws_meta;
|
||||
assert(ws_meta_.flags() & wsrep::provider::flag::commit);
|
||||
@ -93,19 +93,19 @@ int wsrep::transaction_context::start_replaying(const wsrep::ws_meta& ws_meta)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::append_key(const wsrep::key& key)
|
||||
int wsrep::transaction::append_key(const wsrep::key& key)
|
||||
{
|
||||
/** @todo Collect table level keys for SR commit */
|
||||
return provider_.append_key(ws_handle_, key);
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::append_data(const wsrep::const_buffer& data)
|
||||
int wsrep::transaction::append_data(const wsrep::const_buffer& data)
|
||||
{
|
||||
|
||||
return provider_.append_data(ws_handle_, data);
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::after_row()
|
||||
int wsrep::transaction::after_row()
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||
if (streaming_context_.fragment_size() > 0)
|
||||
@ -137,7 +137,7 @@ int wsrep::transaction_context::after_row()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::before_prepare(
|
||||
int wsrep::transaction::before_prepare(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||
{
|
||||
assert(lock.owns_lock());
|
||||
@ -195,7 +195,7 @@ int wsrep::transaction_context::before_prepare(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::after_prepare(
|
||||
int wsrep::transaction::after_prepare(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||
{
|
||||
assert(lock.owns_lock());
|
||||
@ -232,7 +232,7 @@ int wsrep::transaction_context::after_prepare(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::before_commit()
|
||||
int wsrep::transaction::before_commit()
|
||||
{
|
||||
int ret(1);
|
||||
|
||||
@ -334,7 +334,7 @@ int wsrep::transaction_context::before_commit()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::ordered_commit()
|
||||
int wsrep::transaction::ordered_commit()
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||
debug_log_state("ordered_commit_enter");
|
||||
@ -348,7 +348,7 @@ int wsrep::transaction_context::ordered_commit()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::after_commit()
|
||||
int wsrep::transaction::after_commit()
|
||||
{
|
||||
int ret(0);
|
||||
|
||||
@ -383,7 +383,7 @@ int wsrep::transaction_context::after_commit()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::before_rollback()
|
||||
int wsrep::transaction::before_rollback()
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||
debug_log_state("before_rollback_enter");
|
||||
@ -440,7 +440,7 @@ int wsrep::transaction_context::before_rollback()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::after_rollback()
|
||||
int wsrep::transaction::after_rollback()
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||
debug_log_state("after_rollback_enter");
|
||||
@ -462,7 +462,7 @@ int wsrep::transaction_context::after_rollback()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::after_statement()
|
||||
int wsrep::transaction::after_statement()
|
||||
{
|
||||
int ret(0);
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
|
||||
@ -565,7 +565,7 @@ int wsrep::transaction_context::after_statement()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool wsrep::transaction_context::bf_abort(
|
||||
bool wsrep::transaction::bf_abort(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
|
||||
wsrep::seqno bf_seqno)
|
||||
{
|
||||
@ -634,7 +634,7 @@ bool wsrep::transaction_context::bf_abort(
|
||||
// otherwise it could happend that the client gains control
|
||||
// between releasing the lock and before background
|
||||
// rollbacker gets control.
|
||||
state(lock, wsrep::transaction_context::s_aborting);
|
||||
state(lock, wsrep::transaction::s_aborting);
|
||||
lock.unlock();
|
||||
client_state_.server_context().background_rollback(client_state_);
|
||||
}
|
||||
@ -646,9 +646,9 @@ bool wsrep::transaction_context::bf_abort(
|
||||
// Private //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void wsrep::transaction_context::state(
|
||||
void wsrep::transaction::state(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
|
||||
enum wsrep::transaction_context::state next_state)
|
||||
enum wsrep::transaction::state next_state)
|
||||
{
|
||||
if (client_state_.debug_log_level() >= 1)
|
||||
{
|
||||
@ -689,7 +689,7 @@ void wsrep::transaction_context::state(
|
||||
}
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::certify_fragment(
|
||||
int wsrep::transaction::certify_fragment(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||
{
|
||||
assert(lock.owns_lock());
|
||||
@ -717,7 +717,7 @@ int wsrep::transaction_context::certify_fragment(
|
||||
}
|
||||
|
||||
// Client context to store fragment in separate transaction
|
||||
// Switch temporarily to sr_transaction_context, switch back
|
||||
// Switch temporarily to sr_transaction, switch back
|
||||
// to original when this goes out of scope
|
||||
// std::auto_ptr<wsrep::client_state> sr_client_state(
|
||||
// client_state_.server_context().local_client_state());
|
||||
@ -731,12 +731,12 @@ int wsrep::transaction_context::certify_fragment(
|
||||
sr_client_state);
|
||||
|
||||
wsrep::unique_lock<wsrep::mutex> sr_lock(sr_client_state.mutex());
|
||||
wsrep::transaction_context& sr_transaction_context(
|
||||
wsrep::transaction& sr_transaction(
|
||||
sr_client_state.transaction_);
|
||||
sr_transaction_context.state(sr_lock, s_certifying);
|
||||
sr_transaction.state(sr_lock, s_certifying);
|
||||
sr_lock.unlock();
|
||||
if (sr_client_state.append_fragment(
|
||||
sr_transaction_context, flags_,
|
||||
sr_transaction, flags_,
|
||||
wsrep::const_buffer(data.data(), data.size())))
|
||||
{
|
||||
lock.lock();
|
||||
@ -747,18 +747,18 @@ int wsrep::transaction_context::certify_fragment(
|
||||
|
||||
enum wsrep::provider::status
|
||||
cert_ret(provider_.certify(client_state_.id().get(),
|
||||
sr_transaction_context.ws_handle_,
|
||||
sr_transaction.ws_handle_,
|
||||
flags_,
|
||||
sr_transaction_context.ws_meta_));
|
||||
sr_transaction.ws_meta_));
|
||||
|
||||
int ret(0);
|
||||
switch (cert_ret)
|
||||
{
|
||||
case wsrep::provider::success:
|
||||
streaming_context_.certified(sr_transaction_context.ws_meta().seqno());
|
||||
streaming_context_.certified(sr_transaction.ws_meta().seqno());
|
||||
sr_lock.lock();
|
||||
sr_transaction_context.certified_ = true;
|
||||
sr_transaction_context.state(sr_lock, s_committing);
|
||||
sr_transaction.certified_ = true;
|
||||
sr_transaction.state(sr_lock, s_committing);
|
||||
sr_lock.unlock();
|
||||
if (sr_client_state.commit())
|
||||
{
|
||||
@ -767,7 +767,7 @@ int wsrep::transaction_context::certify_fragment(
|
||||
break;
|
||||
default:
|
||||
sr_lock.lock();
|
||||
sr_transaction_context.state(sr_lock, s_must_abort);
|
||||
sr_transaction.state(sr_lock, s_must_abort);
|
||||
sr_lock.unlock();
|
||||
sr_client_state.rollback();
|
||||
ret = 1;
|
||||
@ -786,7 +786,7 @@ int wsrep::transaction_context::certify_fragment(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::transaction_context::certify_commit(
|
||||
int wsrep::transaction::certify_commit(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||
{
|
||||
assert(lock.owns_lock());
|
||||
@ -925,7 +925,7 @@ int wsrep::transaction_context::certify_commit(
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::streaming_rollback()
|
||||
void wsrep::transaction::streaming_rollback()
|
||||
{
|
||||
assert(streaming_context_.rolled_back() == false);
|
||||
wsrep::client_state* sac(
|
||||
@ -938,12 +938,12 @@ void wsrep::transaction_context::streaming_rollback()
|
||||
provider_.rollback(id_.get());
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::clear_fragments()
|
||||
void wsrep::transaction::clear_fragments()
|
||||
{
|
||||
streaming_context_.cleanup();
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::cleanup()
|
||||
void wsrep::transaction::cleanup()
|
||||
{
|
||||
assert(is_streaming() == false);
|
||||
assert(state() == s_committed || state() == s_aborted);
|
||||
@ -958,7 +958,7 @@ void wsrep::transaction_context::cleanup()
|
||||
debug_log_state("cleanup_leave");
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::debug_log_state(
|
||||
void wsrep::transaction::debug_log_state(
|
||||
const char* context) const
|
||||
{
|
||||
WSREP_TC_LOG_DEBUG(
|
Reference in New Issue
Block a user