1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-06-13 04:01:32 +03:00

Renamed client_context to client_state.

This commit is contained in:
Teemu Ollakka
2018-06-17 10:00:13 +03:00
parent 97ee96987e
commit dd28b173ab
33 changed files with 518 additions and 518 deletions

View File

@ -7,14 +7,14 @@
db::client::client(db::server& server,
wsrep::client_id client_id,
enum wsrep::client_context::mode mode,
enum wsrep::client_state::mode mode,
const db::params& params)
: mutex_()
, params_(params)
, server_(server)
, server_context_(server.server_context())
, client_context_(mutex_, this, server_context_, client_service_, client_id, mode)
, client_service_(server_context_.provider(), client_context_)
, client_state_(mutex_, this, server_context_, client_service_, client_id, mode)
, client_service_(server_context_.provider(), client_state_)
, se_trx_(server.storage_engine())
, stats_()
{ }
@ -30,7 +30,7 @@ void db::client::start()
bool db::client::bf_abort(wsrep::seqno seqno)
{
return client_context_.bf_abort(seqno);
return client_state_.bf_abort(seqno);
}
////////////////////////////////////////////////////////////////////////////////
@ -40,39 +40,39 @@ bool db::client::bf_abort(wsrep::seqno seqno)
template <class F>
int db::client::client_command(F f)
{
int err(client_context_.before_command());
int err(client_state_.before_command());
// wsrep::log_debug() << "before_command: " << err;
// If err != 0, transaction was BF aborted while client idle
if (err == 0)
{
err = client_context_.before_statement();
err = client_state_.before_statement();
if (err == 0)
{
err = f();
}
client_context_.after_statement();
client_state_.after_statement();
}
client_context_.after_command_before_result();
if (client_context_.current_error())
client_state_.after_command_before_result();
if (client_state_.current_error())
{
// wsrep::log_info() << "Current error";
assert(client_context_.transaction().state() ==
assert(client_state_.transaction().state() ==
wsrep::transaction_context::s_aborted);
err = 1;
}
client_context_.after_command_after_result();
client_state_.after_command_after_result();
// wsrep::log_info() << "client_command(): " << err;
return err;
}
void db::client::run_one_transaction()
{
client_context_.reset_error();
client_state_.reset_error();
int err = client_command(
[&]()
{
// wsrep::log_debug() << "Start transaction";
err = client_context_.start_transaction(
err = client_state_.start_transaction(
server_.next_transaction_id());
assert(err == 0);
se_trx_.start(this);
@ -80,7 +80,7 @@ void db::client::run_one_transaction()
});
const wsrep::transaction_context& transaction(
client_context_.transaction());
client_state_.transaction());
err = err || client_command(
[&]()
@ -93,11 +93,11 @@ void db::client::run_one_transaction()
os << data;
wsrep::key key(wsrep::key::exclusive);
key.append_key_part("dbms", 4);
unsigned long long client_key(client_context_.id().get());
unsigned long long client_key(client_state_.id().get());
key.append_key_part(&client_key, sizeof(client_key));
key.append_key_part(&data, sizeof(data));
err = client_context_.append_key(key);
err = err || client_context_.append_data(
err = client_state_.append_key(key);
err = err || client_state_.append_data(
wsrep::const_buffer(os.str().c_str(),
os.str().size()));
return err;
@ -108,18 +108,18 @@ void db::client::run_one_transaction()
{
// wsrep::log_debug() << "Commit";
assert(err == 0);
if (client_context_.do_2pc())
if (client_state_.do_2pc())
{
err = err || client_context_.before_prepare();
err = err || client_context_.after_prepare();
err = err || client_state_.before_prepare();
err = err || client_state_.after_prepare();
}
err = err || client_context_.before_commit();
err = err || client_state_.before_commit();
if (err == 0) se_trx_.commit();
err = err || client_context_.ordered_commit();
err = err || client_context_.after_commit();
err = err || client_state_.ordered_commit();
err = err || client_state_.after_commit();
if (err)
{
client_context_.rollback();
client_state_.rollback();
}
return err;
});
@ -147,7 +147,7 @@ void db::client::report_progress(size_t i) const
{
if ((i % 1000) == 0)
{
wsrep::log_info() << "client: " << client_context_.id().get()
wsrep::log_info() << "client: " << client_state_.id().get()
<< " transactions: " << i
<< " " << 100*double(i)/params_.n_transactions << "%";
}

View File

@ -7,7 +7,7 @@
#include "db_server_context.hpp"
#include "db_storage_engine.hpp"
#include "db_client_context.hpp"
#include "db_client_state.hpp"
#include "db_client_service.hpp"
@ -30,18 +30,18 @@ namespace db
};
client(db::server&,
wsrep::client_id,
enum wsrep::client_context::mode,
enum wsrep::client_state::mode,
const db::params&);
bool bf_abort(wsrep::seqno);
const struct stats stats() const { return stats_; }
void store_globals()
{
client_context_.store_globals();
client_state_.store_globals();
}
void reset_globals()
{ }
void start();
wsrep::client_context& client_context() { return client_context_; }
wsrep::client_state& client_state() { return client_state_; }
private:
friend class db::server_context;
friend class db::client_service;
@ -53,7 +53,7 @@ namespace db
const db::params& params_;
db::server& server_;
db::server_context& server_context_;
db::client_context client_context_;
db::client_state client_state_;
db::client_service client_service_;
db::storage_engine::transaction se_trx_;
struct stats stats_;

View File

@ -5,47 +5,47 @@
#include "db_client_service.hpp"
#include "db_client.hpp"
int db::client_service::apply(wsrep::client_context&,
int db::client_service::apply(wsrep::client_state&,
const wsrep::const_buffer&)
{
db::client* client(client_context_.client());
db::client* client(client_state_.client());
client->se_trx_.start(client);
client->se_trx_.apply(client_context_.transaction());
client->se_trx_.apply(client_state_.transaction());
return 0;
}
int db::client_service::commit(wsrep::client_context&,
int db::client_service::commit(wsrep::client_state&,
const wsrep::ws_handle&,
const wsrep::ws_meta&)
{
db::client* client(client_context_.client());
int ret(client_context_.before_commit());
db::client* client(client_state_.client());
int ret(client_state_.before_commit());
if (ret == 0) client->se_trx_.commit();
ret = ret || client_context_.ordered_commit();
ret = ret || client_context_.after_commit();
ret = ret || client_state_.ordered_commit();
ret = ret || client_state_.after_commit();
return ret;
}
int db::client_service::rollback(wsrep::client_context&)
int db::client_service::rollback(wsrep::client_state&)
{
db::client* client(client_context_.client());
int ret(client_context_.before_rollback());
db::client* client(client_state_.client());
int ret(client_state_.before_rollback());
assert(ret == 0);
client->se_trx_.rollback();
ret = client_context_.after_rollback();
ret = client_state_.after_rollback();
assert(ret == 0);
return ret;
}
enum wsrep::provider::status
db::client_service::replay(wsrep::client_context&,
db::client_service::replay(wsrep::client_state&,
wsrep::transaction_context& transaction_context)
{
wsrep::high_priority_context high_priority_context(client_context_);
wsrep::high_priority_context high_priority_context(client_state_);
auto ret(provider_.replay(transaction_context.ws_handle(),
&client_context_));
&client_state_));
if (ret == wsrep::provider::success)
{
++client_context_.client()->stats_.replays;
++client_state_.client()->stats_.replays;
}
return ret;
}

View File

@ -8,7 +8,7 @@
#include "wsrep/client_service.hpp"
#include "wsrep/transaction_context.hpp"
#include "db_client_context.hpp"
#include "db_client_state.hpp"
namespace db
{
@ -16,19 +16,19 @@ namespace db
{
public:
client_service(wsrep::provider& provider,
db::client_context& client_context)
db::client_state& client_state)
: wsrep::client_service(provider)
, client_context_(client_context)
, client_state_(client_state)
{ }
bool is_autocommit() const override
{
return client_context_.is_autocommit();
return client_state_.is_autocommit();
}
bool do_2pc() const override
{
return client_context_.do_2pc();
return client_state_.do_2pc();
}
bool interrupted() const override
@ -38,15 +38,15 @@ namespace db
void reset_globals() override
{
client_context_.reset_globals();
client_state_.reset_globals();
}
void store_globals() override
{
client_context_.store_globals();
client_state_.store_globals();
}
int prepare_data_for_replication(wsrep::client_context&, const wsrep::transaction_context&) override
int prepare_data_for_replication(wsrep::client_state&, const wsrep::transaction_context&) override
{
return 0;
}
@ -56,7 +56,7 @@ namespace db
return 0;
}
int prepare_fragment_for_replication(wsrep::client_context&,
int prepare_fragment_for_replication(wsrep::client_state&,
const wsrep::transaction_context&,
wsrep::mutable_buffer&) override
{
@ -66,19 +66,19 @@ namespace db
void remove_fragments(const wsrep::transaction_context&) override
{ }
int apply(wsrep::client_context&, const wsrep::const_buffer&) override;
int apply(wsrep::client_state&, const wsrep::const_buffer&) override;
int commit(wsrep::client_context&,
int commit(wsrep::client_state&,
const wsrep::ws_handle&, const wsrep::ws_meta&) override;
int rollback(wsrep::client_context&) override;
int rollback(wsrep::client_state&) override;
void will_replay(const wsrep::transaction_context&) override
{ }
void wait_for_replayers(wsrep::client_context&,
void wait_for_replayers(wsrep::client_state&,
wsrep::unique_lock<wsrep::mutex>&) override { }
enum wsrep::provider::status replay(wsrep::client_context&,
enum wsrep::provider::status replay(wsrep::client_state&,
wsrep::transaction_context&)
override;
@ -89,10 +89,10 @@ namespace db
}
void emergency_shutdown() { ::abort(); }
void debug_sync(wsrep::client_context&, const char*) override { }
void debug_sync(wsrep::client_state&, const char*) override { }
void debug_crash(const char*) override { }
private:
db::client_context& client_context_;
db::client_state& client_state_;
};
}

View File

@ -5,22 +5,22 @@
#ifndef WSREP_DB_CLIENT_CONTEXT_HPP
#define WSREP_DB_CLIENT_CONTEXT_HPP
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "db_server_context.hpp"
namespace db
{
class client;
class client_context : public wsrep::client_context
class client_state : public wsrep::client_state
{
public:
client_context(wsrep::mutex& mutex,
client_state(wsrep::mutex& mutex,
db::client* client,
db::server_context& server_context,
wsrep::client_service& client_service,
const wsrep::client_id& client_id,
enum wsrep::client_context::mode mode)
: wsrep::client_context(mutex,
enum wsrep::client_state::mode mode)
: wsrep::client_state(mutex,
server_context,
client_service,
client_id,
@ -31,13 +31,13 @@ namespace db
{ }
db::client* client() { return client_; }
void reset_globals() { }
void store_globals() { wsrep::client_context::store_globals(); }
void store_globals() { wsrep::client_state::store_globals(); }
bool is_autocommit() const { return is_autocommit_; }
bool do_2pc() const { return do_2pc_; }
private:
client_context(const client_context&);
client_context& operator=(const client_context&);
client_state(const client_state&);
client_state& operator=(const client_state&);
db::client* client_;
bool is_autocommit_;
bool do_2pc_;

View File

@ -26,10 +26,10 @@ void db::server::applier_thread()
{
wsrep::client_id client_id(last_client_id_.fetch_add(1) + 1);
db::client applier(*this, client_id,
wsrep::client_context::m_high_priority,
wsrep::client_state::m_high_priority,
simulator_.params());
wsrep::client_context* cc(static_cast<wsrep::client_context*>(
&applier.client_context()));
wsrep::client_state* cc(static_cast<wsrep::client_state*>(
&applier.client_state()));
enum wsrep::provider::status ret(
server_context_.provider().run_applier(cc));
wsrep::log() << "Applier thread exited with error code " << ret;
@ -83,7 +83,7 @@ void db::server::start_client(size_t id)
{
auto client(std::make_shared<db::client>(
*this, id,
wsrep::client_context::m_replicating,
wsrep::client_state::m_replicating,
simulator_.params()));
clients_.push_back(client);
client_threads_.push_back(
@ -97,24 +97,24 @@ void db::server::donate_sst(const std::string& req,
simulator_.sst(*this, req, gtid, bypass);
}
wsrep::client_context* db::server::local_client_context()
wsrep::client_state* db::server::local_client_state()
{
std::ostringstream id_os;
size_t client_id(++last_client_id_);
db::client* client(new db::client(*this, client_id,
wsrep::client_context::m_replicating,
wsrep::client_state::m_replicating,
simulator_.params()));
return &client->client_context();
return &client->client_state();
}
wsrep::client_context* db::server::streaming_applier_client_context()
wsrep::client_state* db::server::streaming_applier_client_state()
{
throw wsrep::not_implemented_error();
}
void db::server::release_client_context(wsrep::client_context* client_context)
void db::server::release_client_state(wsrep::client_state* client_state)
{
db::client_context* db_client_context(
dynamic_cast<db::client_context*>(client_context));
delete db_client_context->client();
db::client_state* db_client_state(
dynamic_cast<db::client_state*>(client_state));
delete db_client_state->client();
}

View File

@ -6,7 +6,7 @@
#define WSREP_DB_SERVER_HPP
#include "wsrep/gtid.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "db_storage_engine.hpp"
#include "db_server_context.hpp"
@ -40,9 +40,9 @@ namespace db
return (last_transaction_id_.fetch_add(1) + 1);
}
void donate_sst(const std::string&, const wsrep::gtid&, bool);
wsrep::client_context* local_client_context();
wsrep::client_context* streaming_applier_client_context();
void release_client_context(wsrep::client_context*);
wsrep::client_state* local_client_state();
wsrep::client_state* streaming_applier_client_state();
void release_client_state(wsrep::client_state*);
private:
void start_client(size_t id);

View File

@ -5,20 +5,20 @@
#include "db_server_context.hpp"
#include "db_server.hpp"
wsrep::client_context* db::server_context::local_client_context()
wsrep::client_state* db::server_context::local_client_state()
{
return server_.local_client_context();
return server_.local_client_state();
}
wsrep::client_context* db::server_context::streaming_applier_client_context()
wsrep::client_state* db::server_context::streaming_applier_client_state()
{
return server_.streaming_applier_client_context();
return server_.streaming_applier_client_state();
}
void db::server_context::release_client_context(
wsrep::client_context* client_context)
void db::server_context::release_client_state(
wsrep::client_state* client_state)
{
server_.release_client_context(client_context);
server_.release_client_state(client_state);
}
bool db::server_context::sst_before_init() const
@ -37,12 +37,12 @@ void db::server_context::on_sst_request(
server_.donate_sst(request, gtid, bypass);
}
void db::server_context::background_rollback(wsrep::client_context&)
void db::server_context::background_rollback(wsrep::client_state&)
{
}
void db::server_context::log_dummy_write_set(
wsrep::client_context&, const wsrep::ws_meta& meta)
wsrep::client_state&, const wsrep::ws_meta& meta)
{
wsrep::log_info() << "Dummy write set: " << meta.seqno();
}

View File

@ -6,7 +6,7 @@
#define WSREP_DB_SERVER_CONTEXT_HPP
#include "wsrep/server_context.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include <atomic>
@ -33,14 +33,14 @@ namespace db
, cond_()
, server_(server)
{ }
wsrep::client_context* local_client_context() override;
wsrep::client_context* streaming_applier_client_context() override;
void release_client_context(wsrep::client_context*) override;
wsrep::client_state* local_client_state() override;
wsrep::client_state* streaming_applier_client_state() override;
void release_client_state(wsrep::client_state*) override;
bool sst_before_init() const override;
void on_sst_request(const std::string&, const wsrep::gtid&, bool) override;
std::string on_sst_required() override;
void background_rollback(wsrep::client_context&) override;
void log_dummy_write_set(wsrep::client_context&, const wsrep::ws_meta&)
void background_rollback(wsrep::client_state&) override;
void log_dummy_write_set(wsrep::client_state&, const wsrep::ws_meta&)
override;
private:
wsrep::default_mutex mutex_;

View File

@ -52,8 +52,8 @@ void db::storage_engine::bf_abort_some(const wsrep::transaction_context& txc)
{
for (auto victim : transactions_)
{
wsrep::client_context& cc(victim->client_context());
if (cc.mode() == wsrep::client_context::m_replicating)
wsrep::client_state& cc(victim->client_state());
if (cc.mode() == wsrep::client_state::m_replicating)
{
if (victim->bf_abort(txc.seqno()))
{

View File

@ -8,7 +8,7 @@
#include "db_params.hpp"
#include "wsrep/mutex.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include <atomic>
#include <unordered_set>

View File

@ -22,7 +22,7 @@
namespace wsrep
{
class transaction_context;
class client_context;
class client_state;
class client_service
{
public:
@ -60,14 +60,14 @@ namespace wsrep
/**
* Set up a data for replication.
*/
virtual int prepare_data_for_replication(wsrep::client_context&, const wsrep::transaction_context&) = 0;
virtual int prepare_data_for_replication(wsrep::client_state&, const wsrep::transaction_context&) = 0;
//
// Streaming
//
virtual size_t bytes_generated() const = 0;
virtual int prepare_fragment_for_replication(
wsrep::client_context&, const wsrep::transaction_context&, wsrep::mutable_buffer&) = 0;
wsrep::client_state&, const wsrep::transaction_context&, wsrep::mutable_buffer&) = 0;
virtual void remove_fragments(const wsrep::transaction_context&) = 0;
//
@ -77,17 +77,17 @@ namespace wsrep
/**
* Apply a write set.
*/
virtual int apply(wsrep::client_context&, const wsrep::const_buffer&) = 0;
virtual int apply(wsrep::client_state&, const wsrep::const_buffer&) = 0;
/**
* Commit transaction.
*/
virtual int commit(wsrep::client_context&, const wsrep::ws_handle&, const wsrep::ws_meta&) = 0;
virtual int commit(wsrep::client_state&, const wsrep::ws_handle&, const wsrep::ws_meta&) = 0;
/**
* Roll back transaction.
*/
virtual int rollback(wsrep::client_context&) = 0;
virtual int rollback(wsrep::client_state&) = 0;
//
// Interface to global server state
@ -114,13 +114,13 @@ namespace wsrep
/**
* Replay the current transaction. The implementation must put
* the caller Client Context into applying mode and call
* client_context::replay().
* client_state::replay().
*
* @todo This should not be visible to DBMS level, should be
* handled internally by wsrep-lib.
*/
virtual enum wsrep::provider::status replay(
wsrep::client_context&,
wsrep::client_state&,
wsrep::transaction_context&) = 0;
/**
@ -130,7 +130,7 @@ namespace wsrep
* @todo This should not be visible to DBMS level, should be
* handled internally by wsrep-lib.
*/
virtual void wait_for_replayers(wsrep::client_context&, wsrep::unique_lock<wsrep::mutex>&) = 0;
virtual void wait_for_replayers(wsrep::client_state&, wsrep::unique_lock<wsrep::mutex>&) = 0;
// Streaming replication
/**
@ -146,7 +146,7 @@ namespace wsrep
*
* @params sync_point Name of the debug sync point.
*/
virtual void debug_sync(wsrep::client_context&, const char* sync_point) = 0;
virtual void debug_sync(wsrep::client_state&, const char* sync_point) = 0;
/**
* Forcefully kill the process if the crash_point has

View File

@ -2,7 +2,7 @@
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
/** @file client_context.hpp
/** @file client_state.hpp
*
* Client Context
* ==============
@ -80,7 +80,7 @@ namespace wsrep
*
* Client Contex abstract interface.
*/
class client_context
class client_state
{
public:
/**
@ -136,7 +136,7 @@ namespace wsrep
/**
* Destructor.
*/
virtual ~client_context()
virtual ~client_state()
{
assert(transaction_.active() == false);
}
@ -538,7 +538,7 @@ namespace wsrep
* Client context constuctor. This is protected so that it
* can be called from derived class constructors only.
*/
client_context(wsrep::mutex& mutex,
client_state(wsrep::mutex& mutex,
wsrep::server_context& server_context,
wsrep::client_service& client_service,
const client_id& id,
@ -557,10 +557,10 @@ namespace wsrep
{ }
private:
client_context(const client_context&);
client_context& operator=(client_context&);
client_state(const client_state&);
client_state& operator=(client_state&);
friend class client_context_switch;
friend class client_state_switch;
friend class high_priority_context;
friend class client_toi_mode;
friend class transaction_context;
@ -593,84 +593,84 @@ namespace wsrep
};
class client_context_switch
class client_state_switch
{
public:
client_context_switch(wsrep::client_context& orig_context,
wsrep::client_context& current_context)
client_state_switch(wsrep::client_state& orig_context,
wsrep::client_state& current_context)
: orig_context_(orig_context)
, current_context_(current_context)
{
current_context_.client_service_.store_globals();
}
~client_context_switch()
~client_state_switch()
{
orig_context_.client_service_.store_globals();
}
private:
client_context& orig_context_;
client_context& current_context_;
client_state& orig_context_;
client_state& current_context_;
};
class high_priority_context
{
public:
high_priority_context(wsrep::client_context& client)
high_priority_context(wsrep::client_state& client)
: client_(client)
, orig_mode_(client.mode_)
{
client_.mode_ = wsrep::client_context::m_high_priority;
client_.mode_ = wsrep::client_state::m_high_priority;
}
~high_priority_context()
{
client_.mode_ = orig_mode_;
}
private:
wsrep::client_context& client_;
enum wsrep::client_context::mode orig_mode_;
wsrep::client_state& client_;
enum wsrep::client_state::mode orig_mode_;
};
class client_toi_mode
{
public:
client_toi_mode(wsrep::client_context& client)
client_toi_mode(wsrep::client_state& client)
: client_(client)
, orig_mode_(client.mode_)
{
client_.mode_ = wsrep::client_context::m_toi;
client_.mode_ = wsrep::client_state::m_toi;
}
~client_toi_mode()
{
assert(client_.mode() == wsrep::client_context::m_toi);
assert(client_.mode() == wsrep::client_state::m_toi);
client_.mode_ = orig_mode_;
}
private:
wsrep::client_context& client_;
enum wsrep::client_context::mode orig_mode_;
wsrep::client_state& client_;
enum wsrep::client_state::mode orig_mode_;
};
template <class D>
class scoped_client_context
class scoped_client_state
{
public:
scoped_client_context(wsrep::client_context* client_context, D deleter)
: client_context_(client_context)
scoped_client_state(wsrep::client_state* client_state, D deleter)
: client_state_(client_state)
, deleter_(deleter)
{
if (client_context_ == 0)
if (client_state_ == 0)
{
throw wsrep::runtime_error("Null client_context provided");
throw wsrep::runtime_error("Null client_state provided");
}
}
wsrep::client_context& client_context() { return *client_context_; }
~scoped_client_context()
wsrep::client_state& client_state() { return *client_state_; }
~scoped_client_state()
{
deleter_(client_context_);
deleter_(client_state_);
}
private:
scoped_client_context(const scoped_client_context&);
scoped_client_context& operator=(const scoped_client_context&);
wsrep::client_context* client_context_;
scoped_client_state(const scoped_client_state&);
scoped_client_state& operator=(const scoped_client_state&);
wsrep::client_state* client_state_;
D deleter_;
};
}

View File

@ -74,7 +74,7 @@ namespace wsrep
class ws_handle;
class ws_meta;
class provider;
class client_context;
class client_state;
class transaction_id;
class transaction_context;
class id;
@ -199,7 +199,7 @@ namespace wsrep
*
* @return Pointer to Client Context.
*/
virtual client_context* local_client_context() = 0;
virtual client_state* local_client_state() = 0;
/**
* Create applier context for streaming transaction.
@ -208,24 +208,24 @@ namespace wsrep
* @param transaction_id Transaction ID of the SR transaction on the
* origin server.
*/
virtual client_context* streaming_applier_client_context() = 0;
virtual client_state* streaming_applier_client_state() = 0;
virtual void release_client_context(wsrep::client_context*) = 0;
virtual void release_client_state(wsrep::client_state*) = 0;
void start_streaming_applier(
const wsrep::id&,
const wsrep::transaction_id&,
wsrep::client_context* client_context);
wsrep::client_state* client_state);
void stop_streaming_applier(
const wsrep::id&, const wsrep::transaction_id&);
/**
* Return reference to streaming applier.
*/
client_context* find_streaming_applier(const wsrep::id&,
client_state* find_streaming_applier(const wsrep::id&,
const wsrep::transaction_id&) const;
virtual void log_dummy_write_set(wsrep::client_context&,
virtual void log_dummy_write_set(wsrep::client_state&,
const wsrep::ws_meta&) = 0;
/**
* Load WSRep provider.
@ -333,7 +333,7 @@ namespace wsrep
const wsrep::gtid& gtid,
bool bypass) = 0;
virtual void background_rollback(wsrep::client_context&) = 0;
virtual void background_rollback(wsrep::client_state&) = 0;
/**
*
*/
@ -364,13 +364,13 @@ namespace wsrep
*
* @todo Make this private, allow calls for provider implementations
* only.
* @param client_context Applier client context.
* @param client_state Applier client context.
* @param transaction_context Transaction context.
* @param data Write set data
*
* @return Zero on success, non-zero on failure.
*/
int on_apply(wsrep::client_context& client_context,
int on_apply(wsrep::client_state& client_state,
const wsrep::ws_handle& ws_handle,
const wsrep::ws_meta& ws_meta,
const wsrep::const_buffer& data);
@ -384,7 +384,7 @@ namespace wsrep
* replication, false otherwise.
*/
virtual bool statement_allowed_for_streaming(
const wsrep::client_context& client_context,
const wsrep::client_state& client_state,
const wsrep::transaction_context& transaction_context) const;
void debug_log_level(int level) { debug_log_level_ = level; }
@ -435,7 +435,7 @@ namespace wsrep
wsrep::condition_variable& cond_;
enum state state_;
mutable std::vector<int> state_waiters_;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>, wsrep::client_context*> streaming_appliers_map;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>, wsrep::client_state*> streaming_appliers_map;
streaming_appliers_map streaming_appliers_;
wsrep::provider* provider_;
std::string name_;
@ -452,9 +452,9 @@ namespace wsrep
client_deleter(wsrep::server_context& server_context)
: server_context_(server_context)
{ }
void operator()(wsrep::client_context* client_context)
void operator()(wsrep::client_state* client_state)
{
server_context_.release_client_context(client_context);
server_context_.release_client_state(client_state);
}
private:
wsrep::server_context& server_context_;

View File

@ -16,7 +16,7 @@
namespace wsrep
{
class client_context;
class client_state;
class key;
class const_buffer;
@ -43,7 +43,7 @@ namespace wsrep
enum state state() const
{ return state_; }
transaction_context(wsrep::client_context& client_context);
transaction_context(wsrep::client_state& client_state);
~transaction_context();
// Accessors
wsrep::transaction_id id() const
@ -136,7 +136,7 @@ namespace wsrep
void debug_log_state(const char*) const;
wsrep::provider& provider_;
wsrep::client_context& client_context_;
wsrep::client_state& client_state_;
wsrep::transaction_id id_;
enum state state_;
std::vector<enum state> state_hist_;

View File

@ -3,7 +3,7 @@
#
add_library(wsrep-lib
client_context.cpp
client_state.cpp
id.cpp
logger.cpp
provider.cpp

View File

@ -2,7 +2,7 @@
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/compiler.hpp"
#include "wsrep/logger.hpp"
@ -10,12 +10,12 @@
#include <iostream>
wsrep::provider& wsrep::client_context::provider() const
wsrep::provider& wsrep::client_state::provider() const
{
return server_context_.provider();
}
void wsrep::client_context::override_error(enum wsrep::client_error error)
void wsrep::client_state::override_error(enum wsrep::client_error error)
{
assert(wsrep::this_thread::get_id() == thread_id_);
if (current_error_ != wsrep::e_success &&
@ -27,7 +27,7 @@ void wsrep::client_context::override_error(enum wsrep::client_error error)
}
int wsrep::client_context::before_command()
int wsrep::client_state::before_command()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
debug_log_state("before_command: enter");
@ -71,7 +71,7 @@ int wsrep::client_context::before_command()
else if (transaction_.state() == wsrep::transaction_context::s_aborted)
{
// Transaction was rolled back either just before sending result
// to the client, or after client_context become idle.
// to the client, or after client_state become idle.
// Clean up the transaction and return error.
override_error(wsrep::e_deadlock_error);
lock.unlock();
@ -86,7 +86,7 @@ int wsrep::client_context::before_command()
return 0;
}
void wsrep::client_context::after_command_before_result()
void wsrep::client_state::after_command_before_result()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
debug_log_state("after_command_before_result: enter");
@ -106,7 +106,7 @@ void wsrep::client_context::after_command_before_result()
debug_log_state("after_command_before_result: leave");
}
void wsrep::client_context::after_command_after_result()
void wsrep::client_state::after_command_after_result()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
debug_log_state("after_command_after_result_enter");
@ -129,7 +129,7 @@ void wsrep::client_context::after_command_after_result()
debug_log_state("after_command_after_result: leave");
}
int wsrep::client_context::before_statement()
int wsrep::client_state::before_statement()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
debug_log_state("before_statement: enter");
@ -156,8 +156,8 @@ int wsrep::client_context::before_statement()
return 0;
}
enum wsrep::client_context::after_statement_result
wsrep::client_context::after_statement()
enum wsrep::client_state::after_statement_result
wsrep::client_state::after_statement()
{
// wsrep::unique_lock<wsrep::mutex> lock(mutex_);
debug_log_state("after_statement: enter");
@ -187,20 +187,20 @@ wsrep::client_context::after_statement()
// Private
void wsrep::client_context::debug_log_state(const char* context) const
void wsrep::client_state::debug_log_state(const char* context) const
{
if (debug_log_level() >= 1)
{
wsrep::log_debug() << "client_context: " << context
wsrep::log_debug() << "client_state: " << context
<< ": server: " << server_context_.name()
<< " client: " << id_.get()
<< " current_error: " << current_error_;
}
}
void wsrep::client_context::state(
void wsrep::client_state::state(
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
enum wsrep::client_context::state state)
enum wsrep::client_state::state state)
{
assert(wsrep::this_thread::get_id() == thread_id_);
assert(lock.owns_lock());
@ -219,7 +219,7 @@ void wsrep::client_context::state(
else
{
std::ostringstream os;
os << "client_context: Unallowed state transition: "
os << "client_state: Unallowed state transition: "
<< state_ << " -> " << state;
throw wsrep::runtime_error(os.str());
}

View File

@ -3,7 +3,7 @@
//
#include "wsrep/server_context.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/transaction_context.hpp"
#include "wsrep/view.hpp"
#include "wsrep/logger.hpp"
@ -118,14 +118,14 @@ void wsrep::server_context::on_sync()
}
int wsrep::server_context::on_apply(
wsrep::client_context& client_context,
wsrep::client_state& client_state,
const wsrep::ws_handle& ws_handle,
const wsrep::ws_meta& ws_meta,
const wsrep::const_buffer& data)
{
int ret(0);
const wsrep::transaction_context& txc(client_context.transaction());
assert(client_context.mode() == wsrep::client_context::m_high_priority);
const wsrep::transaction_context& txc(client_state.transaction());
assert(client_state.mode() == wsrep::client_state::m_high_priority);
bool not_replaying(txc.state() !=
wsrep::transaction_context::s_replaying);
@ -135,35 +135,35 @@ int wsrep::server_context::on_apply(
{
if (not_replaying)
{
client_context.before_command();
client_context.before_statement();
client_state.before_command();
client_state.before_statement();
assert(txc.active() == false);
client_context.start_transaction(ws_handle, ws_meta);
client_state.start_transaction(ws_handle, ws_meta);
}
else
{
client_context.start_replaying(ws_meta);
client_state.start_replaying(ws_meta);
}
if (client_context.apply(data))
if (client_state.apply(data))
{
ret = 1;
}
else if (client_context.commit())
else if (client_state.commit())
{
ret = 1;
}
if (ret)
{
client_context.rollback();
client_state.rollback();
}
if (not_replaying)
{
client_context.after_statement();
client_context.after_command_before_result();
client_context.after_command_after_result();
client_state.after_statement();
client_state.after_command_before_result();
client_state.after_command_after_result();
}
assert(ret ||
txc.state() == wsrep::transaction_context::s_committed);
@ -173,7 +173,7 @@ int wsrep::server_context::on_apply(
assert(not_replaying);
assert(find_streaming_applier(
ws_meta.server_id(), ws_meta.transaction_id()) == 0);
wsrep::client_context* sac(streaming_applier_client_context());
wsrep::client_state* sac(streaming_applier_client_state());
start_streaming_applier(
ws_meta.server_id(), ws_meta.transaction_id(), sac);
sac->start_transaction(ws_handle, ws_meta);
@ -183,7 +183,7 @@ int wsrep::server_context::on_apply(
// introduce a virtual method call which takes
// both original and sac client contexts as argument
// and a functor which does the applying.
wsrep::client_context_switch sw(client_context, *sac);
wsrep::client_state_switch sw(client_state, *sac);
sac->before_command();
sac->before_statement();
sac->apply(data);
@ -191,11 +191,11 @@ int wsrep::server_context::on_apply(
sac->after_command_before_result();
sac->after_command_after_result();
}
log_dummy_write_set(client_context, ws_meta);
log_dummy_write_set(client_state, ws_meta);
}
else if (ws_meta.flags() == 0)
{
wsrep::client_context* sac(
wsrep::client_state* sac(
find_streaming_applier(
ws_meta.server_id(), ws_meta.transaction_id()));
if (sac == 0)
@ -211,7 +211,7 @@ int wsrep::server_context::on_apply(
}
else
{
wsrep::client_context_switch(client_context, *sac);
wsrep::client_state_switch(client_state, *sac);
sac->before_command();
sac->before_statement();
ret = sac->apply(data);
@ -219,13 +219,13 @@ int wsrep::server_context::on_apply(
sac->after_command_before_result();
sac->after_command_after_result();
}
log_dummy_write_set(client_context, ws_meta);
log_dummy_write_set(client_state, ws_meta);
}
else if (commits_transaction(ws_meta.flags()))
{
if (not_replaying)
{
wsrep::client_context* sac(
wsrep::client_state* sac(
find_streaming_applier(
ws_meta.server_id(), ws_meta.transaction_id()));
assert(sac);
@ -242,7 +242,7 @@ int wsrep::server_context::on_apply(
}
else
{
wsrep::client_context_switch(client_context, *sac);
wsrep::client_state_switch(client_state, *sac);
sac->before_command();
sac->before_statement();
ret = sac->commit();
@ -251,14 +251,14 @@ int wsrep::server_context::on_apply(
sac->after_command_after_result();
stop_streaming_applier(
ws_meta.server_id(), ws_meta.transaction_id());
release_client_context(sac);
release_client_state(sac);
}
}
else
{
ret = client_context.start_replaying(ws_meta) ||
client_context.apply(wsrep::const_buffer()) ||
client_context.commit();
ret = client_state.start_replaying(ws_meta) ||
client_state.apply(wsrep::const_buffer()) ||
client_state.commit();
}
}
else
@ -274,7 +274,7 @@ int wsrep::server_context::on_apply(
}
bool wsrep::server_context::statement_allowed_for_streaming(
const wsrep::client_context&,
const wsrep::client_state&,
const wsrep::transaction_context&) const
{
/* Streaming not implemented yet. */
@ -284,14 +284,14 @@ bool wsrep::server_context::statement_allowed_for_streaming(
void wsrep::server_context::start_streaming_applier(
const wsrep::id& server_id,
const wsrep::transaction_id& transaction_id,
wsrep::client_context* client_context)
wsrep::client_state* client_state)
{
if (streaming_appliers_.insert(
std::make_pair(std::make_pair(server_id, transaction_id),
client_context)).second == false)
client_state)).second == false)
{
wsrep::log_error() << "Could not insert streaming applier";
delete client_context;
delete client_state;
throw wsrep::fatal_error();
}
}
@ -314,7 +314,7 @@ void wsrep::server_context::stop_streaming_applier(
}
}
wsrep::client_context* wsrep::server_context::find_streaming_applier(
wsrep::client_state* wsrep::server_context::find_streaming_applier(
const wsrep::id& server_id,
const wsrep::transaction_id& transaction_id) const
{

View File

@ -15,7 +15,7 @@ namespace
wsrep::server_context::rm_sync)
, cc(sc,
wsrep::client_id(1),
wsrep::client_context::m_applier,
wsrep::client_state::m_applier,
false)
, ws_handle(1, (void*)1)
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
@ -27,7 +27,7 @@ namespace
cc.start_transaction(ws_handle, ws_meta);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
wsrep::ws_handle ws_handle;
wsrep::ws_meta ws_meta;
};

View File

@ -3,7 +3,7 @@
//
#include "wsrep/transaction_context.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/server_context.hpp"
#include "wsrep/key.hpp"
#include "wsrep/logger.hpp"
@ -14,7 +14,7 @@
#define WSREP_TC_LOG_DEBUG(level, msg) \
do { \
if (client_context_.debug_log_level() < level) \
if (client_state_.debug_log_level() < level) \
{ } \
else wsrep::log_debug() << msg; \
} while (0)
@ -22,9 +22,9 @@
// Public
wsrep::transaction_context::transaction_context(
wsrep::client_context& client_context)
: provider_(client_context.provider())
, client_context_(client_context)
wsrep::client_state& client_state)
: provider_(client_state.provider())
, client_state_(client_state)
, id_(transaction_id::invalid())
, state_(s_executing)
, state_hist_()
@ -52,12 +52,12 @@ int wsrep::transaction_context::start_transaction(
state_hist_.clear();
ws_handle_ = wsrep::ws_handle(id);
flags_ |= wsrep::provider::flag::start_transaction;
switch (client_context_.mode())
switch (client_state_.mode())
{
case wsrep::client_context::m_local:
case wsrep::client_context::m_high_priority:
case wsrep::client_state::m_local:
case wsrep::client_state::m_high_priority:
return 0;
case wsrep::client_context::m_replicating:
case wsrep::client_state::m_replicating:
return provider_.start_transaction(ws_handle_);
default:
assert(0);
@ -72,7 +72,7 @@ int wsrep::transaction_context::start_transaction(
assert(ws_meta.flags());
assert(active() == false);
id_ = ws_meta.transaction_id();
assert(client_context_.mode() == wsrep::client_context::m_high_priority);
assert(client_state_.mode() == wsrep::client_state::m_high_priority);
state_ = s_executing;
state_hist_.clear();
ws_handle_ = ws_handle;
@ -86,7 +86,7 @@ int wsrep::transaction_context::start_replaying(const wsrep::ws_meta& ws_meta)
ws_meta_ = ws_meta;
assert(ws_meta_.flags() & wsrep::provider::flag::commit);
assert(active());
assert(client_context_.mode() == wsrep::client_context::m_high_priority);
assert(client_state_.mode() == wsrep::client_state::m_high_priority);
assert(state() == s_replaying);
assert(ws_meta_.seqno().nil() == false);
certified_ = true;
@ -107,7 +107,7 @@ int wsrep::transaction_context::append_data(const wsrep::const_buffer& data)
int wsrep::transaction_context::after_row()
{
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
if (streaming_context_.fragment_size() > 0)
{
switch (streaming_context_.fragment_unit())
@ -122,7 +122,7 @@ int wsrep::transaction_context::after_row()
}
break;
case streaming_context::bytes:
if (client_context_.bytes_generated() >=
if (client_state_.bytes_generated() >=
streaming_context_.bytes_certified()
+ streaming_context_.fragment_size())
{
@ -148,41 +148,41 @@ int wsrep::transaction_context::before_prepare(
if (state() == s_must_abort)
{
assert(client_context_.mode() == wsrep::client_context::m_replicating);
client_context_.override_error(wsrep::e_deadlock_error);
assert(client_state_.mode() == wsrep::client_state::m_replicating);
client_state_.override_error(wsrep::e_deadlock_error);
return 1;
}
state(lock, s_preparing);
switch (client_context_.mode())
switch (client_state_.mode())
{
case wsrep::client_context::m_replicating:
case wsrep::client_state::m_replicating:
if (is_streaming())
{
client_context_.debug_crash(
client_state_.debug_crash(
"crash_last_fragment_commit_before_fragment_removal");
lock.unlock();
if (client_context_.server_context().statement_allowed_for_streaming(
client_context_, *this))
if (client_state_.server_context().statement_allowed_for_streaming(
client_state_, *this))
{
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
ret = 1;
}
else
{
client_context_.remove_fragments();
client_state_.remove_fragments();
}
lock.lock();
client_context_.debug_crash(
client_state_.debug_crash(
"crash_last_fragment_commit_after_fragment_removal");
}
break;
case wsrep::client_context::m_local:
case wsrep::client_context::m_high_priority:
case wsrep::client_state::m_local:
case wsrep::client_state::m_high_priority:
if (is_streaming())
{
client_context_.remove_fragments();
client_state_.remove_fragments();
}
break;
default:
@ -204,22 +204,22 @@ int wsrep::transaction_context::after_prepare(
assert(state() == s_preparing || state() == s_must_abort);
if (state() == s_must_abort)
{
assert(client_context_.mode() == wsrep::client_context::m_replicating);
client_context_.override_error(wsrep::e_deadlock_error);
assert(client_state_.mode() == wsrep::client_state::m_replicating);
client_state_.override_error(wsrep::e_deadlock_error);
return 1;
}
switch (client_context_.mode())
switch (client_state_.mode())
{
case wsrep::client_context::m_replicating:
case wsrep::client_state::m_replicating:
ret = certify_commit(lock);
assert((ret == 0 && state() == s_committing) ||
(state() == s_must_abort ||
state() == s_must_replay ||
state() == s_cert_failed));
break;
case wsrep::client_context::m_local:
case wsrep::client_context::m_high_priority:
case wsrep::client_state::m_local:
case wsrep::client_state::m_high_priority:
state(lock, s_certifying);
state(lock, s_committing);
ret = 0;
@ -236,9 +236,9 @@ int wsrep::transaction_context::before_commit()
{
int ret(1);
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("before_commit_enter");
assert(client_context_.mode() != wsrep::client_context::m_toi);
assert(client_state_.mode() != wsrep::client_state::m_toi);
assert(state() == s_executing ||
state() == s_committing ||
state() == s_must_abort ||
@ -246,18 +246,18 @@ int wsrep::transaction_context::before_commit()
assert((state() != s_committing && state() != s_replaying) ||
certified());
switch (client_context_.mode())
switch (client_state_.mode())
{
case wsrep::client_context::m_local:
case wsrep::client_state::m_local:
if (ordered())
{
ret = provider_.commit_order_enter(ws_handle_, ws_meta_);
}
break;
case wsrep::client_context::m_replicating:
case wsrep::client_state::m_replicating:
if (state() == s_executing)
{
assert(client_context_.do_2pc() == false);
assert(client_state_.do_2pc() == false);
ret = before_prepare(lock) || after_prepare(lock);
assert((ret == 0 && state() == s_committing)
||
@ -274,7 +274,7 @@ int wsrep::transaction_context::before_commit()
}
else
{
client_context_.override_error(wsrep::e_deadlock_error);
client_state_.override_error(wsrep::e_deadlock_error);
}
}
else
@ -309,10 +309,10 @@ int wsrep::transaction_context::before_commit()
}
}
break;
case wsrep::client_context::m_high_priority:
case wsrep::client_state::m_high_priority:
assert(certified());
assert(ordered());
if (client_context_.do_2pc() == false)
if (client_state_.do_2pc() == false)
{
ret = before_prepare(lock) || after_prepare(lock);
}
@ -336,7 +336,7 @@ int wsrep::transaction_context::before_commit()
int wsrep::transaction_context::ordered_commit()
{
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("ordered_commit_enter");
assert(state() == s_committing);
assert(ordered());
@ -352,26 +352,26 @@ int wsrep::transaction_context::after_commit()
{
int ret(0);
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("after_commit_enter");
assert(state() == s_ordered_commit);
if (is_streaming())
{
assert(client_context_.mode() == wsrep::client_context::m_replicating ||
client_context_.mode() == wsrep::client_context::m_high_priority);
assert(client_state_.mode() == wsrep::client_state::m_replicating ||
client_state_.mode() == wsrep::client_state::m_high_priority);
clear_fragments();
}
switch (client_context_.mode())
switch (client_state_.mode())
{
case wsrep::client_context::m_local:
case wsrep::client_state::m_local:
// Nothing to do
break;
case wsrep::client_context::m_replicating:
case wsrep::client_state::m_replicating:
ret = provider_.release(ws_handle_);
break;
case wsrep::client_context::m_high_priority:
case wsrep::client_state::m_high_priority:
break;
default:
assert(0);
@ -385,7 +385,7 @@ int wsrep::transaction_context::after_commit()
int wsrep::transaction_context::before_rollback()
{
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("before_rollback_enter");
assert(state() == s_executing ||
state() == s_must_abort ||
@ -442,7 +442,7 @@ int wsrep::transaction_context::before_rollback()
int wsrep::transaction_context::after_rollback()
{
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("after_rollback_enter");
assert(state() == s_aborting ||
state() == s_must_replay);
@ -465,7 +465,7 @@ int wsrep::transaction_context::after_rollback()
int wsrep::transaction_context::after_statement()
{
int ret(0);
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex());
debug_log_state("after_statement_enter");
assert(state() == s_executing ||
state() == s_committed ||
@ -496,9 +496,9 @@ int wsrep::transaction_context::after_statement()
break;
case s_must_abort:
case s_cert_failed:
client_context_.override_error(wsrep::e_deadlock_error);
client_state_.override_error(wsrep::e_deadlock_error);
lock.unlock();
ret = client_context_.rollback();
ret = client_state_.rollback();
lock.lock();
if (state() != s_must_replay)
{
@ -510,19 +510,19 @@ int wsrep::transaction_context::after_statement()
{
state(lock, s_replaying);
lock.unlock();
enum wsrep::provider::status replay_ret(client_context_.replay(*this));
enum wsrep::provider::status replay_ret(client_state_.replay(*this));
switch (replay_ret)
{
case wsrep::provider::success:
provider_.release(ws_handle_);
break;
case wsrep::provider::error_certification_failed:
client_context_.override_error(
client_state_.override_error(
wsrep::e_deadlock_error);
ret = 1;
break;
default:
client_context_.emergency_shutdown();
client_state_.emergency_shutdown();
break;
}
lock.lock();
@ -593,7 +593,7 @@ bool wsrep::transaction_context::bf_abort(
{
wsrep::seqno victim_seqno;
enum wsrep::provider::status
status(client_context_.provider().bf_abort(
status(client_state_.provider().bf_abort(
bf_seqno, id_.get(), victim_seqno));
switch (status)
{
@ -624,9 +624,9 @@ bool wsrep::transaction_context::bf_abort(
if (ret)
{
bf_abort_client_state_ = client_context_.state();
if (client_context_.state() == wsrep::client_context::s_idle &&
client_context_.server_context().rollback_mode() ==
bf_abort_client_state_ = client_state_.state();
if (client_state_.state() == wsrep::client_state::s_idle &&
client_state_.server_context().rollback_mode() ==
wsrep::server_context::rm_sync)
{
// We need to change the state to aborting under the
@ -636,7 +636,7 @@ bool wsrep::transaction_context::bf_abort(
// rollbacker gets control.
state(lock, wsrep::transaction_context::s_aborting);
lock.unlock();
client_context_.server_context().background_rollback(client_context_);
client_state_.server_context().background_rollback(client_state_);
}
}
return ret;
@ -650,9 +650,9 @@ void wsrep::transaction_context::state(
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
enum wsrep::transaction_context::state next_state)
{
if (client_context_.debug_log_level() >= 1)
if (client_state_.debug_log_level() >= 1)
{
log_debug() << "client: " << client_context_.id().get()
log_debug() << "client: " << client_state_.id().get()
<< " txc: " << id().get()
<< " state: " << to_string(state_)
<< " -> " << to_string(next_state);
@ -694,13 +694,13 @@ int wsrep::transaction_context::certify_fragment(
{
assert(lock.owns_lock());
assert(client_context_.mode() == wsrep::client_context::m_replicating);
assert(client_state_.mode() == wsrep::client_state::m_replicating);
assert(streaming_context_.rolled_back() == false);
client_context_.wait_for_replayers(lock);
client_state_.wait_for_replayers(lock);
if (state() == s_must_abort)
{
client_context_.override_error(wsrep::e_deadlock_error);
client_state_.override_error(wsrep::e_deadlock_error);
return 1;
}
@ -709,7 +709,7 @@ int wsrep::transaction_context::certify_fragment(
lock.unlock();
wsrep::mutable_buffer data;
if (client_context_.prepare_fragment_for_replication(*this, data))
if (client_state_.prepare_fragment_for_replication(*this, data))
{
lock.lock();
state(lock, s_must_abort);
@ -719,34 +719,34 @@ int wsrep::transaction_context::certify_fragment(
// Client context to store fragment in separate transaction
// Switch temporarily to sr_transaction_context, switch back
// to original when this goes out of scope
// std::auto_ptr<wsrep::client_context> sr_client_context(
// client_context_.server_context().local_client_context());
wsrep::scoped_client_context<wsrep::client_deleter> sr_client_context_scope(
client_context_.server_context().local_client_context(),
wsrep::client_deleter(client_context_.server_context()));
wsrep::client_context& sr_client_context(
sr_client_context_scope.client_context());
wsrep::client_context_switch client_context_switch(
client_context_,
sr_client_context);
// std::auto_ptr<wsrep::client_state> sr_client_state(
// client_state_.server_context().local_client_state());
wsrep::scoped_client_state<wsrep::client_deleter> sr_client_state_scope(
client_state_.server_context().local_client_state(),
wsrep::client_deleter(client_state_.server_context()));
wsrep::client_state& sr_client_state(
sr_client_state_scope.client_state());
wsrep::client_state_switch client_state_switch(
client_state_,
sr_client_state);
wsrep::unique_lock<wsrep::mutex> sr_lock(sr_client_context.mutex());
wsrep::unique_lock<wsrep::mutex> sr_lock(sr_client_state.mutex());
wsrep::transaction_context& sr_transaction_context(
sr_client_context.transaction_);
sr_client_state.transaction_);
sr_transaction_context.state(sr_lock, s_certifying);
sr_lock.unlock();
if (sr_client_context.append_fragment(
if (sr_client_state.append_fragment(
sr_transaction_context, flags_,
wsrep::const_buffer(data.data(), data.size())))
{
lock.lock();
state(lock, s_must_abort);
client_context_.override_error(wsrep::e_append_fragment_error);
client_state_.override_error(wsrep::e_append_fragment_error);
return 1;
}
enum wsrep::provider::status
cert_ret(provider_.certify(client_context_.id().get(),
cert_ret(provider_.certify(client_state_.id().get(),
sr_transaction_context.ws_handle_,
flags_,
sr_transaction_context.ws_meta_));
@ -760,7 +760,7 @@ int wsrep::transaction_context::certify_fragment(
sr_transaction_context.certified_ = true;
sr_transaction_context.state(sr_lock, s_committing);
sr_lock.unlock();
if (sr_client_context.commit())
if (sr_client_state.commit())
{
ret = 1;
}
@ -769,7 +769,7 @@ int wsrep::transaction_context::certify_fragment(
sr_lock.lock();
sr_transaction_context.state(sr_lock, s_must_abort);
sr_lock.unlock();
sr_client_context.rollback();
sr_client_state.rollback();
ret = 1;
break;
}
@ -791,13 +791,13 @@ int wsrep::transaction_context::certify_commit(
{
assert(lock.owns_lock());
assert(active());
client_context_.wait_for_replayers(lock);
client_state_.wait_for_replayers(lock);
assert(lock.owns_lock());
if (state() == s_must_abort)
{
client_context_.override_error(wsrep::e_deadlock_error);
client_state_.override_error(wsrep::e_deadlock_error);
return 1;
}
@ -807,30 +807,30 @@ int wsrep::transaction_context::certify_commit(
lock.unlock();
if (client_context_.prepare_data_for_replication(*this))
if (client_state_.prepare_data_for_replication(*this))
{
// Note: Error must be set by prepare_data_for_replication()
lock.lock();
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
state(lock, s_must_abort);
return 1;
}
if (client_context_.interrupted())
if (client_state_.interrupted())
{
lock.lock();
client_context_.override_error(wsrep::e_interrupted_error);
client_state_.override_error(wsrep::e_interrupted_error);
state(lock, s_must_abort);
return 1;
}
client_context_.debug_sync("wsrep_before_certification");
client_state_.debug_sync("wsrep_before_certification");
enum wsrep::provider::status
cert_ret(provider_.certify(client_context_.id().get(),
cert_ret(provider_.certify(client_state_.id().get(),
ws_handle_,
flags(),
ws_meta_));
client_context_.debug_sync("wsrep_after_certification");
client_state_.debug_sync("wsrep_after_certification");
lock.lock();
@ -852,7 +852,7 @@ int wsrep::transaction_context::certify_commit(
// We got BF aborted after succesful certification
// and before acquiring client context lock. This means that
// the trasaction must be replayed.
client_context_.will_replay(*this);
client_state_.will_replay(*this);
state(lock, s_must_replay);
break;
default:
@ -863,14 +863,14 @@ int wsrep::transaction_context::certify_commit(
case wsrep::provider::error_warning:
assert(ordered() == false);
state(lock, s_must_abort);
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
break;
case wsrep::provider::error_transaction_missing:
state(lock, s_must_abort);
// The execution should never reach this point if the
// transaction has not generated any keys or data.
wsrep::log_warning() << "Transaction was missing in provider";
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
break;
case wsrep::provider::error_bf_abort:
// Transaction was replicated succesfully and it was either
@ -878,7 +878,7 @@ int wsrep::transaction_context::certify_commit(
// yet known. Therefore the transaction must roll back
// and go through replay either to replay and commit the whole
// transaction or to determine failed certification status.
client_context_.will_replay(*this);
client_state_.will_replay(*this);
if (state() != s_must_abort)
{
state(lock, s_must_abort);
@ -887,11 +887,11 @@ int wsrep::transaction_context::certify_commit(
break;
case wsrep::provider::error_certification_failed:
state(lock, s_cert_failed);
client_context_.override_error(wsrep::e_deadlock_error);
client_state_.override_error(wsrep::e_deadlock_error);
break;
case wsrep::provider::error_size_exceeded:
state(lock, s_must_abort);
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
break;
case wsrep::provider::error_connection_failed:
case wsrep::provider::error_provider_failed:
@ -901,16 +901,16 @@ int wsrep::transaction_context::certify_commit(
{
state(lock, s_must_abort);
}
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
break;
case wsrep::provider::error_fatal:
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
state(lock, s_must_abort);
client_context_.emergency_shutdown();
client_state_.emergency_shutdown();
break;
case wsrep::provider::error_not_implemented:
case wsrep::provider::error_not_allowed:
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
state(lock, s_must_abort);
wsrep::log_warning() << "Certification operation was not allowed: "
<< "id: " << id().get()
@ -918,7 +918,7 @@ int wsrep::transaction_context::certify_commit(
break;
default:
state(lock, s_must_abort);
client_context_.override_error(wsrep::e_error_during_commit);
client_state_.override_error(wsrep::e_error_during_commit);
break;
}
@ -928,10 +928,10 @@ int wsrep::transaction_context::certify_commit(
void wsrep::transaction_context::streaming_rollback()
{
assert(streaming_context_.rolled_back() == false);
wsrep::client_context* sac(
client_context_.server_context().streaming_applier_client_context());
client_context_.server_context().start_streaming_applier(
client_context_.server_context().id(), id(), sac);
wsrep::client_state* sac(
client_state_.server_context().streaming_applier_client_state());
client_state_.server_context().start_streaming_applier(
client_state_.server_context().id(), id(), sac);
sac->adopt_transaction(*this);
streaming_context_.cleanup();
// Replicate rollback fragment
@ -963,10 +963,10 @@ void wsrep::transaction_context::debug_log_state(
{
WSREP_TC_LOG_DEBUG(
1, context
<< ": server: " << client_context_.server_context().name()
<< " client: " << client_context_.id().get()
<< ": server: " << client_state_.server_context().name()
<< " client: " << client_state_.id().get()
<< " trx: " << int64_t(id_.get())
<< " state: " << wsrep::to_string(state_)
<< " error: "
<< wsrep::to_string(client_context_.current_error()));
<< wsrep::to_string(client_state_.current_error()));
}

View File

@ -5,7 +5,7 @@
#include "wsrep_provider_v26.hpp"
#include "wsrep/server_context.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/view.hpp"
#include "wsrep/exception.hpp"
@ -309,10 +309,10 @@ namespace
{
wsrep_cb_status_t ret(WSREP_CB_SUCCESS);
wsrep::client_context* client_context(
reinterpret_cast<wsrep::client_context*>(ctx));
assert(client_context);
assert(client_context->mode() == wsrep::client_context::m_high_priority);
wsrep::client_state* client_state(
reinterpret_cast<wsrep::client_state*>(ctx));
assert(client_state);
assert(client_state->mode() == wsrep::client_state::m_high_priority);
wsrep::const_buffer data(buf->ptr, buf->len);
wsrep::ws_handle ws_handle(wsh->trx_id, wsh->opaque);
@ -326,8 +326,8 @@ namespace
meta->stid.conn), wsrep::seqno(seqno_from_native(meta->depends_on)),
map_flags_from_native(flags));
if (ret == WSREP_CB_SUCCESS &&
client_context->server_context().on_apply(
*client_context, ws_handle, ws_meta, data))
client_state->server_context().on_apply(
*client_state, ws_handle, ws_meta, data))
{
ret = WSREP_CB_FAILURE;
}

View File

@ -3,7 +3,7 @@
#
add_executable(wsrep-lib_test
mock_client_context.cpp
mock_client_state.cpp
test_utils.cpp
id_test.cpp
server_context_test.cpp

View File

@ -6,7 +6,7 @@
#define WSREP_TEST_CLIENT_CONTEXT_FIXTURE_HPP
#include "mock_server_context.hpp"
#include "mock_client_context.hpp"
#include "mock_client_state.hpp"
#include <boost/test/unit_test.hpp>
@ -18,7 +18,7 @@ namespace
replicating_client_fixture_sync_rm()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -28,7 +28,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -37,7 +37,7 @@ namespace
replicating_client_fixture_async_rm()
: sc("s1", "s1", wsrep::server_context::rm_async)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -47,7 +47,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -56,7 +56,7 @@ namespace
replicating_client_fixture_2pc()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
sc.client_service().do_2pc_ = true;
@ -67,7 +67,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -76,7 +76,7 @@ namespace
replicating_client_fixture_autocommit()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
sc.client_service().is_autocommit_ = true;
@ -87,7 +87,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -98,7 +98,7 @@ namespace
wsrep::server_context::rm_async)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_context::m_high_priority)
wsrep::client_state::m_high_priority)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -115,7 +115,7 @@ namespace
BOOST_REQUIRE(tc.ordered() == true);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -126,7 +126,7 @@ namespace
wsrep::server_context::rm_async)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_context::m_high_priority)
wsrep::client_state::m_high_priority)
, tc(cc.transaction())
{
sc.client_service().do_2pc_ = true;
@ -144,7 +144,7 @@ namespace
BOOST_REQUIRE(tc.ordered() == true);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -153,7 +153,7 @@ namespace
streaming_client_fixture_row()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -164,7 +164,7 @@ namespace
cc.enable_streaming(wsrep::streaming_context::row, 1);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -173,7 +173,7 @@ namespace
streaming_client_fixture_byte()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -184,7 +184,7 @@ namespace
cc.enable_streaming(wsrep::streaming_context::bytes, 1);
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
@ -193,7 +193,7 @@ namespace
streaming_client_fixture_statement()
: sc("s1", "s1", wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_context::m_replicating)
wsrep::client_state::m_replicating)
, tc(cc.transaction())
{
BOOST_REQUIRE(cc.before_command() == 0);
@ -205,7 +205,7 @@ namespace
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
const wsrep::transaction_context& tc;
};
}

View File

@ -1,56 +0,0 @@
//
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include "wsrep/transaction_context.hpp"
#include "mock_client_context.hpp"
int wsrep::mock_client_service::apply(
wsrep::client_context& client_context WSREP_UNUSED,
const wsrep::const_buffer&)
{
assert(client_context.transaction().state() == wsrep::transaction_context::s_executing ||
client_context.transaction().state() == wsrep::transaction_context::s_replaying);
return (fail_next_applying_ ? 1 : 0);
}
int wsrep::mock_client_service::commit(wsrep::client_context& client_context, const wsrep::ws_handle&, const wsrep::ws_meta&)
{
int ret(0);
if (do_2pc())
{
if (client_context.before_prepare())
{
ret = 1;
}
else if (client_context.after_prepare())
{
ret = 1;
}
}
if (ret == 0 &&
(client_context.before_commit() ||
client_context.ordered_commit() ||
client_context.after_commit()))
{
ret = 1;
}
return ret;
}
int wsrep::mock_client_service::rollback(
wsrep::client_context& client_context)
{
int ret(0);
if (client_context.before_rollback())
{
ret = 1;
}
else if (client_context.after_rollback())
{
ret = 1;
}
return ret;
}

View File

@ -0,0 +1,56 @@
//
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include "wsrep/transaction_context.hpp"
#include "mock_client_state.hpp"
int wsrep::mock_client_service::apply(
wsrep::client_state& client_state WSREP_UNUSED,
const wsrep::const_buffer&)
{
assert(client_state.transaction().state() == wsrep::transaction_context::s_executing ||
client_state.transaction().state() == wsrep::transaction_context::s_replaying);
return (fail_next_applying_ ? 1 : 0);
}
int wsrep::mock_client_service::commit(wsrep::client_state& client_state, const wsrep::ws_handle&, const wsrep::ws_meta&)
{
int ret(0);
if (do_2pc())
{
if (client_state.before_prepare())
{
ret = 1;
}
else if (client_state.after_prepare())
{
ret = 1;
}
}
if (ret == 0 &&
(client_state.before_commit() ||
client_state.ordered_commit() ||
client_state.after_commit()))
{
ret = 1;
}
return ret;
}
int wsrep::mock_client_service::rollback(
wsrep::client_state& client_state)
{
int ret(0);
if (client_state.before_rollback())
{
ret = 1;
}
else if (client_state.after_rollback())
{
ret = 1;
}
return ret;
}

View File

@ -5,7 +5,7 @@
#ifndef WSREP_MOCK_CLIENT_CONTEXT_HPP
#define WSREP_MOCK_CLIENT_CONTEXT_HPP
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/mutex.hpp"
#include "wsrep/compiler.hpp"
@ -13,19 +13,19 @@
namespace wsrep
{
class mock_client_context : public wsrep::client_context
class mock_client_state : public wsrep::client_state
{
public:
mock_client_context(wsrep::server_context& server_context,
mock_client_state(wsrep::server_context& server_context,
wsrep::client_service& client_service,
const wsrep::client_id& id,
enum wsrep::client_context::mode mode)
: wsrep::client_context(mutex_, server_context, client_service, id, mode)
enum wsrep::client_state::mode mode)
: wsrep::client_state(mutex_, server_context, client_service, id, mode)
// Note: Mutex is initialized only after passed
// to client_context constructor.
// to client_state constructor.
, mutex_()
{ }
~mock_client_context()
~mock_client_state()
{
if (transaction().active())
{
@ -57,12 +57,12 @@ namespace wsrep
, aborts_()
{ }
int apply(wsrep::client_context&, const wsrep::const_buffer&) WSREP_OVERRIDE;
int apply(wsrep::client_state&, const wsrep::const_buffer&) WSREP_OVERRIDE;
int commit(wsrep::client_context&, const wsrep::ws_handle&, const wsrep::ws_meta&)
int commit(wsrep::client_state&, const wsrep::ws_handle&, const wsrep::ws_meta&)
WSREP_OVERRIDE;
int rollback(wsrep::client_context&) WSREP_OVERRIDE;
int rollback(wsrep::client_state&) WSREP_OVERRIDE;
bool is_autocommit() const WSREP_OVERRIDE
{ return is_autocommit_; }
@ -85,30 +85,30 @@ namespace wsrep
WSREP_OVERRIDE { }
enum wsrep::provider::status
replay(wsrep::client_context& client_context,
replay(wsrep::client_state& client_state,
wsrep::transaction_context& tc) WSREP_OVERRIDE
{
enum wsrep::provider::status ret(
provider_.replay(tc.ws_handle(), &client_context));
provider_.replay(tc.ws_handle(), &client_state));
++replays_;
return ret;
}
void wait_for_replayers(
wsrep::client_context& client_context,
wsrep::client_state& client_state,
wsrep::unique_lock<wsrep::mutex>& lock)
WSREP_OVERRIDE
{
lock.unlock();
if (bf_abort_during_wait_)
{
wsrep_test::bf_abort_unordered(client_context);
wsrep_test::bf_abort_unordered(client_state);
}
lock.lock();
}
int prepare_data_for_replication(
wsrep::client_context& client_context,
wsrep::client_state& client_state,
const wsrep::transaction_context&) WSREP_OVERRIDE
{
if (error_during_prepare_data_)
@ -117,7 +117,7 @@ namespace wsrep
}
static const char buf[1] = { 1 };
wsrep::const_buffer data = wsrep::const_buffer(buf, 1);
return client_context.append_data(data);
return client_state.append_data(data);
}
size_t bytes_generated() const
@ -126,7 +126,7 @@ namespace wsrep
}
int prepare_fragment_for_replication(
wsrep::client_context& client_context,
wsrep::client_state& client_state,
const wsrep::transaction_context&,
wsrep::mutable_buffer& buffer)
WSREP_OVERRIDE
@ -138,12 +138,12 @@ namespace wsrep
static const char buf[1] = { 1 };
buffer.push_back(&buf[0], &buf[1]);
wsrep::const_buffer data(buffer.data(), buffer.size());
return client_context.append_data(data);
return client_state.append_data(data);
}
void store_globals() WSREP_OVERRIDE { }
void debug_sync(wsrep::client_context& client_context,
void debug_sync(wsrep::client_state& client_state,
const char* sync_point) WSREP_OVERRIDE
{
if (sync_point_enabled_ == sync_point)
@ -151,10 +151,10 @@ namespace wsrep
switch (sync_point_action_)
{
case spa_bf_abort_unordered:
wsrep_test::bf_abort_unordered(client_context);
wsrep_test::bf_abort_unordered(client_state);
break;
case spa_bf_abort_ordered:
wsrep_test::bf_abort_ordered(client_context);
wsrep_test::bf_abort_ordered(client_state);
break;
}
}

View File

@ -154,8 +154,8 @@ namespace wsrep
enum wsrep::provider::status replay(wsrep::ws_handle&, void* ctx)
{
wsrep::client_context& cc(
*static_cast<wsrep::client_context*>(ctx));
wsrep::client_state& cc(
*static_cast<wsrep::client_state*>(ctx));
wsrep::high_priority_context high_priority_context(cc);
const wsrep::transaction_context& tc(cc.transaction());
wsrep::ws_meta ws_meta;

View File

@ -6,7 +6,7 @@
#define WSREP_MOCK_SERVER_CONTEXT_HPP
#include "wsrep/server_context.hpp"
#include "mock_client_context.hpp"
#include "mock_client_state.hpp"
#include "mock_provider.hpp"
#include "wsrep/compiler.hpp"
@ -29,24 +29,24 @@ namespace wsrep
{ }
wsrep::mock_provider& provider() const
{ return provider_; }
wsrep::client_context* local_client_context()
wsrep::client_state* local_client_state()
{
return new wsrep::mock_client_context(
return new wsrep::mock_client_state(
*this, client_service_, ++last_client_id_,
wsrep::client_context::m_local);
wsrep::client_state::m_local);
}
wsrep::client_context* streaming_applier_client_context()
wsrep::client_state* streaming_applier_client_state()
{
return new wsrep::mock_client_context(
return new wsrep::mock_client_state(
*this, client_service_, ++last_client_id_,
wsrep::client_context::m_high_priority);
wsrep::client_state::m_high_priority);
}
void release_client_context(wsrep::client_context* client_context)
void release_client_state(wsrep::client_state* client_state)
{
delete client_context;
delete client_state;
}
void log_dummy_write_set(wsrep::client_context&,
void log_dummy_write_set(wsrep::client_state&,
const wsrep::ws_meta&)
WSREP_OVERRIDE
{
@ -60,11 +60,11 @@ namespace wsrep
void on_sst_request(const std::string&,
const wsrep::gtid&,
bool) WSREP_OVERRIDE { }
void background_rollback(wsrep::client_context& client_context)
void background_rollback(wsrep::client_state& client_state)
WSREP_OVERRIDE
{
client_context.before_rollback();
client_context.after_rollback();
client_state.before_rollback();
client_state.after_rollback();
}
// void sst_received(const wsrep_gtid_t&, int) WSREP_OVERRIDE { }
// void on_apply(wsrep::transaction_context&) { }

View File

@ -15,7 +15,7 @@ namespace
wsrep::server_context::rm_sync)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_context::m_high_priority)
wsrep::client_state::m_high_priority)
, ws_handle(1, (void*)1)
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
wsrep::stid(wsrep::id("1"), 1, 1),
@ -25,7 +25,7 @@ namespace
{
}
wsrep::mock_server_context sc;
wsrep::mock_client_context cc;
wsrep::mock_client_state cc;
wsrep::ws_handle ws_handle;
wsrep::ws_meta ws_meta;
};
@ -86,10 +86,10 @@ BOOST_AUTO_TEST_CASE(server_context_streaming)
{
wsrep::mock_server_context sc("s1", "s1",
wsrep::server_context::rm_sync);
wsrep::mock_client_context cc(sc,
wsrep::mock_client_state cc(sc,
sc.client_service(),
wsrep::client_id(1),
wsrep::client_context::m_high_priority);
wsrep::client_state::m_high_priority);
wsrep::ws_handle ws_handle(1, (void*)1);
wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
wsrep::stid(wsrep::id("1"), 1, 1),

View File

@ -3,18 +3,18 @@
//
#include "test_utils.hpp"
#include "wsrep/client_context.hpp"
#include "wsrep/client_state.hpp"
#include "mock_server_context.hpp"
// Simple BF abort method to BF abort unordered transasctions
void wsrep_test::bf_abort_unordered(wsrep::client_context& cc)
void wsrep_test::bf_abort_unordered(wsrep::client_state& cc)
{
assert(cc.transaction().ordered() == false);
cc.bf_abort(wsrep::seqno(1));
}
void wsrep_test::bf_abort_ordered(wsrep::client_context& cc)
void wsrep_test::bf_abort_ordered(wsrep::client_state& cc)
{
assert(cc.transaction().ordered());
cc.bf_abort(wsrep::seqno(0));

View File

@ -5,7 +5,7 @@
// Forward declarations
namespace wsrep
{
class client_context;
class client_state;
class mock_server_context;
}
@ -19,10 +19,10 @@ namespace wsrep_test
{
// Simple BF abort method to BF abort unordered transasctions
void bf_abort_unordered(wsrep::client_context& cc);
void bf_abort_unordered(wsrep::client_state& cc);
// Simple BF abort method to BF abort unordered transasctions
void bf_abort_ordered(wsrep::client_context& cc);
void bf_abort_ordered(wsrep::client_state& cc);
// BF abort method to abort transactions via provider
void bf_abort_provider(wsrep::mock_server_context& sc,

View File

@ -6,7 +6,7 @@
#include "wsrep/provider.hpp"
#include "test_utils.hpp"
#include "client_context_fixture.hpp"
#include "client_state_fixture.hpp"
#include <boost/mpl/vector.hpp>
@ -43,7 +43,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_append_key_data,
BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_1pc, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
cc.start_transaction(1);
@ -52,7 +52,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_1pc, T,
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
// Verify that the commit can be succesfully executed in separate command
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
cc.after_command_before_result();
cc.after_command_after_result();
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_1pc, T,
BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_rollback, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -117,7 +117,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_context_1pc_bf_before_before_commit, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -159,7 +159,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -199,7 +199,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -238,7 +238,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -278,7 +278,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -344,7 +344,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(cc.before_commit());
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
BOOST_REQUIRE(tc.active() == false);
@ -360,7 +360,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -403,7 +403,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
cc.start_transaction(1);
@ -421,7 +421,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -436,7 +436,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -477,7 +477,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -518,7 +518,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -559,7 +559,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -600,7 +600,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -641,7 +641,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -683,7 +683,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -725,7 +725,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_client_context& cc(T::cc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -766,7 +766,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_context_1pc_bf_before_before_statement, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -798,7 +798,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_context_1pc_bf_before_after_statement, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
// Start a new transaction with ID 1
@ -820,13 +820,13 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_context_1pc_bf_abort_after_after_statement, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
cc.start_transaction(1);
BOOST_REQUIRE(tc.active());
cc.after_statement();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_exec);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec);
wsrep_test::bf_abort_unordered(cc);
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
BOOST_REQUIRE(tc.active());
@ -853,25 +853,25 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
BOOST_REQUIRE(cc.before_rollback() == 0);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_may_retry);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_may_retry);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_exec);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec);
}
BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_context_1pc_bf_abort_after_after_command_before_result, T,
replicating_fixtures, T)
{
wsrep::client_context& cc(T::cc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction_context& tc(T::tc);
cc.start_transaction(1);
BOOST_REQUIRE(tc.active());
cc.after_statement();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_exec);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec);
cc.after_command_before_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_result);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_result);
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
wsrep_test::bf_abort_unordered(cc);
// The result is being sent to client. We need to mark transaction
@ -882,7 +882,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
// After the result has been sent to the DBMS client, the after result
// processing should roll back the transaction and set the error.
cc.after_command_after_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_idle);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_idle);
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
BOOST_REQUIRE(tc.active() == true);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
@ -902,11 +902,11 @@ BOOST_FIXTURE_TEST_CASE(
cc.start_transaction(1);
BOOST_REQUIRE(tc.active());
cc.after_statement();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_exec);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec);
cc.after_command_before_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_result);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_result);
cc.after_command_after_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_idle);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_idle);
wsrep_test::bf_abort_unordered(cc);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(tc.active());
@ -927,11 +927,11 @@ BOOST_FIXTURE_TEST_CASE(
cc.start_transaction(1);
BOOST_REQUIRE(tc.active());
cc.after_statement();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_exec);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec);
cc.after_command_before_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_result);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_result);
cc.after_command_after_result();
BOOST_REQUIRE(cc.state() == wsrep::client_context::s_idle);
BOOST_REQUIRE(cc.state() == wsrep::client_state::s_idle);
wsrep_test::bf_abort_unordered(cc);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
BOOST_REQUIRE(tc.active());
@ -990,7 +990,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_1pc_commit,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1012,7 +1012,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_batch_streaming_1pc_commit,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1028,14 +1028,14 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(cc.start_transaction(1) == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 2);
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 3);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1052,7 +1052,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_rollback,
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
BOOST_REQUIRE(cc.before_rollback() == 0);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
@ -1072,7 +1072,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_cert_fail_non_commit,
sc.provider().certify_result_ = wsrep::provider::success;
BOOST_REQUIRE(cc.before_rollback() == 0);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
@ -1093,7 +1093,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_cert_fail_commit,
sc.provider().certify_result_ = wsrep::provider::success;
BOOST_REQUIRE(cc.before_rollback() == 0);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
@ -1116,7 +1116,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_bf_abort_committing,
BOOST_REQUIRE(cc.before_rollback() == 0);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
@ -1135,7 +1135,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_byte_streaming_1pc_commit,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1157,7 +1157,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_byte_batch_streaming_1pc_commit,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1173,13 +1173,13 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_statement_streaming_1pc_commit,
BOOST_REQUIRE(cc.start_transaction(1) == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1194,18 +1194,18 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_statement_batch_streaming_1pc_commit
BOOST_REQUIRE(cc.start_transaction(1) == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -1221,7 +1221,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_statement_streaming_cert_fail,
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
sc.provider().certify_result_ = wsrep::provider::error_certification_failed;
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
BOOST_REQUIRE(sc.provider().fragments() == 0);
BOOST_REQUIRE(sc.provider().start_fragments() == 0);

View File

@ -2,7 +2,7 @@
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include "client_context_fixture.hpp"
#include "client_state_fixture.hpp"
//
// Test a succesful 2PC transaction lifecycle
@ -24,7 +24,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc,
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -51,7 +51,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -80,7 +80,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_error);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -108,7 +108,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -140,7 +140,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -172,7 +172,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -195,7 +195,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_2pc_commit,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -207,7 +207,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_2pc_commit_two_statements,
BOOST_REQUIRE(cc.start_transaction(1) == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 2);
@ -216,7 +216,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_2pc_commit_two_statements,
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(sc.provider().fragments() == 3);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -239,7 +239,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc_applying,
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
BOOST_REQUIRE(cc.after_statement() == wsrep::client_state::asr_success);
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);