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:
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
db::client::client(db::server& server,
|
db::client::client(db::server& server,
|
||||||
wsrep::client_id client_id,
|
wsrep::client_id client_id,
|
||||||
enum wsrep::client_context::mode mode,
|
enum wsrep::client_state::mode mode,
|
||||||
const db::params& params)
|
const db::params& params)
|
||||||
: mutex_()
|
: mutex_()
|
||||||
, params_(params)
|
, params_(params)
|
||||||
, server_(server)
|
, server_(server)
|
||||||
, server_context_(server.server_context())
|
, server_context_(server.server_context())
|
||||||
, client_context_(mutex_, this, server_context_, client_service_, client_id, mode)
|
, client_state_(mutex_, this, server_context_, client_service_, client_id, mode)
|
||||||
, client_service_(server_context_.provider(), client_context_)
|
, client_service_(server_context_.provider(), client_state_)
|
||||||
, se_trx_(server.storage_engine())
|
, se_trx_(server.storage_engine())
|
||||||
, stats_()
|
, stats_()
|
||||||
{ }
|
{ }
|
||||||
@ -30,7 +30,7 @@ void db::client::start()
|
|||||||
|
|
||||||
bool db::client::bf_abort(wsrep::seqno seqno)
|
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>
|
template <class F>
|
||||||
int db::client::client_command(F 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;
|
// wsrep::log_debug() << "before_command: " << err;
|
||||||
// If err != 0, transaction was BF aborted while client idle
|
// If err != 0, transaction was BF aborted while client idle
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
err = client_context_.before_statement();
|
err = client_state_.before_statement();
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
err = f();
|
err = f();
|
||||||
}
|
}
|
||||||
client_context_.after_statement();
|
client_state_.after_statement();
|
||||||
}
|
}
|
||||||
client_context_.after_command_before_result();
|
client_state_.after_command_before_result();
|
||||||
if (client_context_.current_error())
|
if (client_state_.current_error())
|
||||||
{
|
{
|
||||||
// wsrep::log_info() << "Current error";
|
// wsrep::log_info() << "Current error";
|
||||||
assert(client_context_.transaction().state() ==
|
assert(client_state_.transaction().state() ==
|
||||||
wsrep::transaction_context::s_aborted);
|
wsrep::transaction_context::s_aborted);
|
||||||
err = 1;
|
err = 1;
|
||||||
}
|
}
|
||||||
client_context_.after_command_after_result();
|
client_state_.after_command_after_result();
|
||||||
// wsrep::log_info() << "client_command(): " << err;
|
// wsrep::log_info() << "client_command(): " << err;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void db::client::run_one_transaction()
|
void db::client::run_one_transaction()
|
||||||
{
|
{
|
||||||
client_context_.reset_error();
|
client_state_.reset_error();
|
||||||
int err = client_command(
|
int err = client_command(
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
// wsrep::log_debug() << "Start transaction";
|
// wsrep::log_debug() << "Start transaction";
|
||||||
err = client_context_.start_transaction(
|
err = client_state_.start_transaction(
|
||||||
server_.next_transaction_id());
|
server_.next_transaction_id());
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
se_trx_.start(this);
|
se_trx_.start(this);
|
||||||
@ -80,7 +80,7 @@ void db::client::run_one_transaction()
|
|||||||
});
|
});
|
||||||
|
|
||||||
const wsrep::transaction_context& transaction(
|
const wsrep::transaction_context& transaction(
|
||||||
client_context_.transaction());
|
client_state_.transaction());
|
||||||
|
|
||||||
err = err || client_command(
|
err = err || client_command(
|
||||||
[&]()
|
[&]()
|
||||||
@ -93,11 +93,11 @@ void db::client::run_one_transaction()
|
|||||||
os << data;
|
os << data;
|
||||||
wsrep::key key(wsrep::key::exclusive);
|
wsrep::key key(wsrep::key::exclusive);
|
||||||
key.append_key_part("dbms", 4);
|
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(&client_key, sizeof(client_key));
|
||||||
key.append_key_part(&data, sizeof(data));
|
key.append_key_part(&data, sizeof(data));
|
||||||
err = client_context_.append_key(key);
|
err = client_state_.append_key(key);
|
||||||
err = err || client_context_.append_data(
|
err = err || client_state_.append_data(
|
||||||
wsrep::const_buffer(os.str().c_str(),
|
wsrep::const_buffer(os.str().c_str(),
|
||||||
os.str().size()));
|
os.str().size()));
|
||||||
return err;
|
return err;
|
||||||
@ -108,18 +108,18 @@ void db::client::run_one_transaction()
|
|||||||
{
|
{
|
||||||
// wsrep::log_debug() << "Commit";
|
// wsrep::log_debug() << "Commit";
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
if (client_context_.do_2pc())
|
if (client_state_.do_2pc())
|
||||||
{
|
{
|
||||||
err = err || client_context_.before_prepare();
|
err = err || client_state_.before_prepare();
|
||||||
err = err || client_context_.after_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();
|
if (err == 0) se_trx_.commit();
|
||||||
err = err || client_context_.ordered_commit();
|
err = err || client_state_.ordered_commit();
|
||||||
err = err || client_context_.after_commit();
|
err = err || client_state_.after_commit();
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
client_context_.rollback();
|
client_state_.rollback();
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
@ -147,7 +147,7 @@ void db::client::report_progress(size_t i) const
|
|||||||
{
|
{
|
||||||
if ((i % 1000) == 0)
|
if ((i % 1000) == 0)
|
||||||
{
|
{
|
||||||
wsrep::log_info() << "client: " << client_context_.id().get()
|
wsrep::log_info() << "client: " << client_state_.id().get()
|
||||||
<< " transactions: " << i
|
<< " transactions: " << i
|
||||||
<< " " << 100*double(i)/params_.n_transactions << "%";
|
<< " " << 100*double(i)/params_.n_transactions << "%";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "db_server_context.hpp"
|
#include "db_server_context.hpp"
|
||||||
#include "db_storage_engine.hpp"
|
#include "db_storage_engine.hpp"
|
||||||
#include "db_client_context.hpp"
|
#include "db_client_state.hpp"
|
||||||
#include "db_client_service.hpp"
|
#include "db_client_service.hpp"
|
||||||
|
|
||||||
|
|
||||||
@ -30,18 +30,18 @@ namespace db
|
|||||||
};
|
};
|
||||||
client(db::server&,
|
client(db::server&,
|
||||||
wsrep::client_id,
|
wsrep::client_id,
|
||||||
enum wsrep::client_context::mode,
|
enum wsrep::client_state::mode,
|
||||||
const db::params&);
|
const db::params&);
|
||||||
bool bf_abort(wsrep::seqno);
|
bool bf_abort(wsrep::seqno);
|
||||||
const struct stats stats() const { return stats_; }
|
const struct stats stats() const { return stats_; }
|
||||||
void store_globals()
|
void store_globals()
|
||||||
{
|
{
|
||||||
client_context_.store_globals();
|
client_state_.store_globals();
|
||||||
}
|
}
|
||||||
void reset_globals()
|
void reset_globals()
|
||||||
{ }
|
{ }
|
||||||
void start();
|
void start();
|
||||||
wsrep::client_context& client_context() { return client_context_; }
|
wsrep::client_state& client_state() { return client_state_; }
|
||||||
private:
|
private:
|
||||||
friend class db::server_context;
|
friend class db::server_context;
|
||||||
friend class db::client_service;
|
friend class db::client_service;
|
||||||
@ -53,7 +53,7 @@ namespace db
|
|||||||
const db::params& params_;
|
const db::params& params_;
|
||||||
db::server& server_;
|
db::server& server_;
|
||||||
db::server_context& server_context_;
|
db::server_context& server_context_;
|
||||||
db::client_context client_context_;
|
db::client_state client_state_;
|
||||||
db::client_service client_service_;
|
db::client_service client_service_;
|
||||||
db::storage_engine::transaction se_trx_;
|
db::storage_engine::transaction se_trx_;
|
||||||
struct stats stats_;
|
struct stats stats_;
|
||||||
|
@ -5,47 +5,47 @@
|
|||||||
#include "db_client_service.hpp"
|
#include "db_client_service.hpp"
|
||||||
#include "db_client.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&)
|
const wsrep::const_buffer&)
|
||||||
{
|
{
|
||||||
db::client* client(client_context_.client());
|
db::client* client(client_state_.client());
|
||||||
client->se_trx_.start(client);
|
client->se_trx_.start(client);
|
||||||
client->se_trx_.apply(client_context_.transaction());
|
client->se_trx_.apply(client_state_.transaction());
|
||||||
return 0;
|
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_handle&,
|
||||||
const wsrep::ws_meta&)
|
const wsrep::ws_meta&)
|
||||||
{
|
{
|
||||||
db::client* client(client_context_.client());
|
db::client* client(client_state_.client());
|
||||||
int ret(client_context_.before_commit());
|
int ret(client_state_.before_commit());
|
||||||
if (ret == 0) client->se_trx_.commit();
|
if (ret == 0) client->se_trx_.commit();
|
||||||
ret = ret || client_context_.ordered_commit();
|
ret = ret || client_state_.ordered_commit();
|
||||||
ret = ret || client_context_.after_commit();
|
ret = ret || client_state_.after_commit();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int db::client_service::rollback(wsrep::client_context&)
|
int db::client_service::rollback(wsrep::client_state&)
|
||||||
{
|
{
|
||||||
db::client* client(client_context_.client());
|
db::client* client(client_state_.client());
|
||||||
int ret(client_context_.before_rollback());
|
int ret(client_state_.before_rollback());
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
client->se_trx_.rollback();
|
client->se_trx_.rollback();
|
||||||
ret = client_context_.after_rollback();
|
ret = client_state_.after_rollback();
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
db::client_service::replay(wsrep::client_context&,
|
db::client_service::replay(wsrep::client_state&,
|
||||||
wsrep::transaction_context& transaction_context)
|
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(),
|
auto ret(provider_.replay(transaction_context.ws_handle(),
|
||||||
&client_context_));
|
&client_state_));
|
||||||
if (ret == wsrep::provider::success)
|
if (ret == wsrep::provider::success)
|
||||||
{
|
{
|
||||||
++client_context_.client()->stats_.replays;
|
++client_state_.client()->stats_.replays;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "wsrep/client_service.hpp"
|
#include "wsrep/client_service.hpp"
|
||||||
#include "wsrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
|
|
||||||
#include "db_client_context.hpp"
|
#include "db_client_state.hpp"
|
||||||
|
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
@ -16,19 +16,19 @@ namespace db
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_service(wsrep::provider& provider,
|
client_service(wsrep::provider& provider,
|
||||||
db::client_context& client_context)
|
db::client_state& client_state)
|
||||||
: wsrep::client_service(provider)
|
: wsrep::client_service(provider)
|
||||||
, client_context_(client_context)
|
, client_state_(client_state)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool is_autocommit() const override
|
bool is_autocommit() const override
|
||||||
{
|
{
|
||||||
return client_context_.is_autocommit();
|
return client_state_.is_autocommit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool do_2pc() const override
|
bool do_2pc() const override
|
||||||
{
|
{
|
||||||
return client_context_.do_2pc();
|
return client_state_.do_2pc();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool interrupted() const override
|
bool interrupted() const override
|
||||||
@ -38,15 +38,15 @@ namespace db
|
|||||||
|
|
||||||
void reset_globals() override
|
void reset_globals() override
|
||||||
{
|
{
|
||||||
client_context_.reset_globals();
|
client_state_.reset_globals();
|
||||||
}
|
}
|
||||||
|
|
||||||
void store_globals() override
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ namespace db
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepare_fragment_for_replication(wsrep::client_context&,
|
int prepare_fragment_for_replication(wsrep::client_state&,
|
||||||
const wsrep::transaction_context&,
|
const wsrep::transaction_context&,
|
||||||
wsrep::mutable_buffer&) override
|
wsrep::mutable_buffer&) override
|
||||||
{
|
{
|
||||||
@ -66,19 +66,19 @@ namespace db
|
|||||||
void remove_fragments(const wsrep::transaction_context&) override
|
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;
|
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 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 { }
|
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&)
|
wsrep::transaction_context&)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ namespace db
|
|||||||
}
|
}
|
||||||
|
|
||||||
void emergency_shutdown() { ::abort(); }
|
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 { }
|
void debug_crash(const char*) override { }
|
||||||
private:
|
private:
|
||||||
db::client_context& client_context_;
|
db::client_state& client_state_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,22 +5,22 @@
|
|||||||
#ifndef WSREP_DB_CLIENT_CONTEXT_HPP
|
#ifndef WSREP_DB_CLIENT_CONTEXT_HPP
|
||||||
#define 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"
|
#include "db_server_context.hpp"
|
||||||
|
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
class client;
|
class client;
|
||||||
class client_context : public wsrep::client_context
|
class client_state : public wsrep::client_state
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_context(wsrep::mutex& mutex,
|
client_state(wsrep::mutex& mutex,
|
||||||
db::client* client,
|
db::client* client,
|
||||||
db::server_context& server_context,
|
db::server_context& server_context,
|
||||||
wsrep::client_service& client_service,
|
wsrep::client_service& client_service,
|
||||||
const wsrep::client_id& client_id,
|
const wsrep::client_id& client_id,
|
||||||
enum wsrep::client_context::mode mode)
|
enum wsrep::client_state::mode mode)
|
||||||
: wsrep::client_context(mutex,
|
: wsrep::client_state(mutex,
|
||||||
server_context,
|
server_context,
|
||||||
client_service,
|
client_service,
|
||||||
client_id,
|
client_id,
|
||||||
@ -31,13 +31,13 @@ namespace db
|
|||||||
{ }
|
{ }
|
||||||
db::client* client() { return client_; }
|
db::client* client() { return client_; }
|
||||||
void reset_globals() { }
|
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 is_autocommit() const { return is_autocommit_; }
|
||||||
bool do_2pc() const { return do_2pc_; }
|
bool do_2pc() const { return do_2pc_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
client_context(const client_context&);
|
client_state(const client_state&);
|
||||||
client_context& operator=(const client_context&);
|
client_state& operator=(const client_state&);
|
||||||
db::client* client_;
|
db::client* client_;
|
||||||
bool is_autocommit_;
|
bool is_autocommit_;
|
||||||
bool do_2pc_;
|
bool do_2pc_;
|
@ -26,10 +26,10 @@ void db::server::applier_thread()
|
|||||||
{
|
{
|
||||||
wsrep::client_id client_id(last_client_id_.fetch_add(1) + 1);
|
wsrep::client_id client_id(last_client_id_.fetch_add(1) + 1);
|
||||||
db::client applier(*this, client_id,
|
db::client applier(*this, client_id,
|
||||||
wsrep::client_context::m_high_priority,
|
wsrep::client_state::m_high_priority,
|
||||||
simulator_.params());
|
simulator_.params());
|
||||||
wsrep::client_context* cc(static_cast<wsrep::client_context*>(
|
wsrep::client_state* cc(static_cast<wsrep::client_state*>(
|
||||||
&applier.client_context()));
|
&applier.client_state()));
|
||||||
enum wsrep::provider::status ret(
|
enum wsrep::provider::status ret(
|
||||||
server_context_.provider().run_applier(cc));
|
server_context_.provider().run_applier(cc));
|
||||||
wsrep::log() << "Applier thread exited with error code " << ret;
|
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>(
|
auto client(std::make_shared<db::client>(
|
||||||
*this, id,
|
*this, id,
|
||||||
wsrep::client_context::m_replicating,
|
wsrep::client_state::m_replicating,
|
||||||
simulator_.params()));
|
simulator_.params()));
|
||||||
clients_.push_back(client);
|
clients_.push_back(client);
|
||||||
client_threads_.push_back(
|
client_threads_.push_back(
|
||||||
@ -97,24 +97,24 @@ void db::server::donate_sst(const std::string& req,
|
|||||||
simulator_.sst(*this, req, gtid, bypass);
|
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;
|
std::ostringstream id_os;
|
||||||
size_t client_id(++last_client_id_);
|
size_t client_id(++last_client_id_);
|
||||||
db::client* client(new db::client(*this, client_id,
|
db::client* client(new db::client(*this, client_id,
|
||||||
wsrep::client_context::m_replicating,
|
wsrep::client_state::m_replicating,
|
||||||
simulator_.params()));
|
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();
|
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(
|
db::client_state* db_client_state(
|
||||||
dynamic_cast<db::client_context*>(client_context));
|
dynamic_cast<db::client_state*>(client_state));
|
||||||
delete db_client_context->client();
|
delete db_client_state->client();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define WSREP_DB_SERVER_HPP
|
#define WSREP_DB_SERVER_HPP
|
||||||
|
|
||||||
#include "wsrep/gtid.hpp"
|
#include "wsrep/gtid.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
|
|
||||||
#include "db_storage_engine.hpp"
|
#include "db_storage_engine.hpp"
|
||||||
#include "db_server_context.hpp"
|
#include "db_server_context.hpp"
|
||||||
@ -40,9 +40,9 @@ namespace db
|
|||||||
return (last_transaction_id_.fetch_add(1) + 1);
|
return (last_transaction_id_.fetch_add(1) + 1);
|
||||||
}
|
}
|
||||||
void donate_sst(const std::string&, const wsrep::gtid&, bool);
|
void donate_sst(const std::string&, const wsrep::gtid&, bool);
|
||||||
wsrep::client_context* local_client_context();
|
wsrep::client_state* local_client_state();
|
||||||
wsrep::client_context* streaming_applier_client_context();
|
wsrep::client_state* streaming_applier_client_state();
|
||||||
void release_client_context(wsrep::client_context*);
|
void release_client_state(wsrep::client_state*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void start_client(size_t id);
|
void start_client(size_t id);
|
||||||
|
@ -5,20 +5,20 @@
|
|||||||
#include "db_server_context.hpp"
|
#include "db_server_context.hpp"
|
||||||
#include "db_server.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(
|
void db::server_context::release_client_state(
|
||||||
wsrep::client_context* client_context)
|
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
|
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);
|
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(
|
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();
|
wsrep::log_info() << "Dummy write set: " << meta.seqno();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define WSREP_DB_SERVER_CONTEXT_HPP
|
#define WSREP_DB_SERVER_CONTEXT_HPP
|
||||||
|
|
||||||
#include "wsrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
@ -33,14 +33,14 @@ namespace db
|
|||||||
, cond_()
|
, cond_()
|
||||||
, server_(server)
|
, server_(server)
|
||||||
{ }
|
{ }
|
||||||
wsrep::client_context* local_client_context() override;
|
wsrep::client_state* local_client_state() override;
|
||||||
wsrep::client_context* streaming_applier_client_context() override;
|
wsrep::client_state* streaming_applier_client_state() override;
|
||||||
void release_client_context(wsrep::client_context*) override;
|
void release_client_state(wsrep::client_state*) override;
|
||||||
bool sst_before_init() const override;
|
bool sst_before_init() const override;
|
||||||
void on_sst_request(const std::string&, const wsrep::gtid&, bool) override;
|
void on_sst_request(const std::string&, const wsrep::gtid&, bool) override;
|
||||||
std::string on_sst_required() override;
|
std::string on_sst_required() override;
|
||||||
void background_rollback(wsrep::client_context&) override;
|
void background_rollback(wsrep::client_state&) override;
|
||||||
void log_dummy_write_set(wsrep::client_context&, const wsrep::ws_meta&)
|
void log_dummy_write_set(wsrep::client_state&, const wsrep::ws_meta&)
|
||||||
override;
|
override;
|
||||||
private:
|
private:
|
||||||
wsrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
|
@ -52,8 +52,8 @@ void db::storage_engine::bf_abort_some(const wsrep::transaction_context& txc)
|
|||||||
{
|
{
|
||||||
for (auto victim : transactions_)
|
for (auto victim : transactions_)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(victim->client_context());
|
wsrep::client_state& cc(victim->client_state());
|
||||||
if (cc.mode() == wsrep::client_context::m_replicating)
|
if (cc.mode() == wsrep::client_state::m_replicating)
|
||||||
{
|
{
|
||||||
if (victim->bf_abort(txc.seqno()))
|
if (victim->bf_abort(txc.seqno()))
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "db_params.hpp"
|
#include "db_params.hpp"
|
||||||
|
|
||||||
#include "wsrep/mutex.hpp"
|
#include "wsrep/mutex.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class transaction_context;
|
class transaction_context;
|
||||||
class client_context;
|
class client_state;
|
||||||
class client_service
|
class client_service
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -60,14 +60,14 @@ namespace wsrep
|
|||||||
/**
|
/**
|
||||||
* Set up a data for replication.
|
* 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
|
// Streaming
|
||||||
//
|
//
|
||||||
virtual size_t bytes_generated() const = 0;
|
virtual size_t bytes_generated() const = 0;
|
||||||
virtual int prepare_fragment_for_replication(
|
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;
|
virtual void remove_fragments(const wsrep::transaction_context&) = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -77,17 +77,17 @@ namespace wsrep
|
|||||||
/**
|
/**
|
||||||
* Apply a write set.
|
* 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.
|
* 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.
|
* Roll back transaction.
|
||||||
*/
|
*/
|
||||||
virtual int rollback(wsrep::client_context&) = 0;
|
virtual int rollback(wsrep::client_state&) = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Interface to global server state
|
// Interface to global server state
|
||||||
@ -114,13 +114,13 @@ namespace wsrep
|
|||||||
/**
|
/**
|
||||||
* Replay the current transaction. The implementation must put
|
* Replay the current transaction. The implementation must put
|
||||||
* the caller Client Context into applying mode and call
|
* 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
|
* @todo This should not be visible to DBMS level, should be
|
||||||
* handled internally by wsrep-lib.
|
* handled internally by wsrep-lib.
|
||||||
*/
|
*/
|
||||||
virtual enum wsrep::provider::status replay(
|
virtual enum wsrep::provider::status replay(
|
||||||
wsrep::client_context&,
|
wsrep::client_state&,
|
||||||
wsrep::transaction_context&) = 0;
|
wsrep::transaction_context&) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +130,7 @@ namespace wsrep
|
|||||||
* @todo This should not be visible to DBMS level, should be
|
* @todo This should not be visible to DBMS level, should be
|
||||||
* handled internally by wsrep-lib.
|
* 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
|
// Streaming replication
|
||||||
/**
|
/**
|
||||||
@ -146,7 +146,7 @@ namespace wsrep
|
|||||||
*
|
*
|
||||||
* @params sync_point Name of the debug sync point.
|
* @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
|
* Forcefully kill the process if the crash_point has
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
/** @file client_context.hpp
|
/** @file client_state.hpp
|
||||||
*
|
*
|
||||||
* Client Context
|
* Client Context
|
||||||
* ==============
|
* ==============
|
||||||
@ -80,7 +80,7 @@ namespace wsrep
|
|||||||
*
|
*
|
||||||
* Client Contex abstract interface.
|
* Client Contex abstract interface.
|
||||||
*/
|
*/
|
||||||
class client_context
|
class client_state
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -136,7 +136,7 @@ namespace wsrep
|
|||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~client_context()
|
virtual ~client_state()
|
||||||
{
|
{
|
||||||
assert(transaction_.active() == false);
|
assert(transaction_.active() == false);
|
||||||
}
|
}
|
||||||
@ -538,7 +538,7 @@ namespace wsrep
|
|||||||
* Client context constuctor. This is protected so that it
|
* Client context constuctor. This is protected so that it
|
||||||
* can be called from derived class constructors only.
|
* can be called from derived class constructors only.
|
||||||
*/
|
*/
|
||||||
client_context(wsrep::mutex& mutex,
|
client_state(wsrep::mutex& mutex,
|
||||||
wsrep::server_context& server_context,
|
wsrep::server_context& server_context,
|
||||||
wsrep::client_service& client_service,
|
wsrep::client_service& client_service,
|
||||||
const client_id& id,
|
const client_id& id,
|
||||||
@ -557,10 +557,10 @@ namespace wsrep
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
client_context(const client_context&);
|
client_state(const client_state&);
|
||||||
client_context& operator=(client_context&);
|
client_state& operator=(client_state&);
|
||||||
|
|
||||||
friend class client_context_switch;
|
friend class client_state_switch;
|
||||||
friend class high_priority_context;
|
friend class high_priority_context;
|
||||||
friend class client_toi_mode;
|
friend class client_toi_mode;
|
||||||
friend class transaction_context;
|
friend class transaction_context;
|
||||||
@ -593,84 +593,84 @@ namespace wsrep
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class client_context_switch
|
class client_state_switch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_context_switch(wsrep::client_context& orig_context,
|
client_state_switch(wsrep::client_state& orig_context,
|
||||||
wsrep::client_context& current_context)
|
wsrep::client_state& current_context)
|
||||||
: orig_context_(orig_context)
|
: orig_context_(orig_context)
|
||||||
, current_context_(current_context)
|
, current_context_(current_context)
|
||||||
{
|
{
|
||||||
current_context_.client_service_.store_globals();
|
current_context_.client_service_.store_globals();
|
||||||
}
|
}
|
||||||
~client_context_switch()
|
~client_state_switch()
|
||||||
{
|
{
|
||||||
orig_context_.client_service_.store_globals();
|
orig_context_.client_service_.store_globals();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
client_context& orig_context_;
|
client_state& orig_context_;
|
||||||
client_context& current_context_;
|
client_state& current_context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class high_priority_context
|
class high_priority_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
high_priority_context(wsrep::client_context& client)
|
high_priority_context(wsrep::client_state& client)
|
||||||
: client_(client)
|
: client_(client)
|
||||||
, orig_mode_(client.mode_)
|
, orig_mode_(client.mode_)
|
||||||
{
|
{
|
||||||
client_.mode_ = wsrep::client_context::m_high_priority;
|
client_.mode_ = wsrep::client_state::m_high_priority;
|
||||||
}
|
}
|
||||||
~high_priority_context()
|
~high_priority_context()
|
||||||
{
|
{
|
||||||
client_.mode_ = orig_mode_;
|
client_.mode_ = orig_mode_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
wsrep::client_context& client_;
|
wsrep::client_state& client_;
|
||||||
enum wsrep::client_context::mode orig_mode_;
|
enum wsrep::client_state::mode orig_mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class client_toi_mode
|
class client_toi_mode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_toi_mode(wsrep::client_context& client)
|
client_toi_mode(wsrep::client_state& client)
|
||||||
: client_(client)
|
: client_(client)
|
||||||
, orig_mode_(client.mode_)
|
, orig_mode_(client.mode_)
|
||||||
{
|
{
|
||||||
client_.mode_ = wsrep::client_context::m_toi;
|
client_.mode_ = wsrep::client_state::m_toi;
|
||||||
}
|
}
|
||||||
~client_toi_mode()
|
~client_toi_mode()
|
||||||
{
|
{
|
||||||
assert(client_.mode() == wsrep::client_context::m_toi);
|
assert(client_.mode() == wsrep::client_state::m_toi);
|
||||||
client_.mode_ = orig_mode_;
|
client_.mode_ = orig_mode_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
wsrep::client_context& client_;
|
wsrep::client_state& client_;
|
||||||
enum wsrep::client_context::mode orig_mode_;
|
enum wsrep::client_state::mode orig_mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class D>
|
template <class D>
|
||||||
class scoped_client_context
|
class scoped_client_state
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
scoped_client_context(wsrep::client_context* client_context, D deleter)
|
scoped_client_state(wsrep::client_state* client_state, D deleter)
|
||||||
: client_context_(client_context)
|
: client_state_(client_state)
|
||||||
, deleter_(deleter)
|
, 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_; }
|
wsrep::client_state& client_state() { return *client_state_; }
|
||||||
~scoped_client_context()
|
~scoped_client_state()
|
||||||
{
|
{
|
||||||
deleter_(client_context_);
|
deleter_(client_state_);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
scoped_client_context(const scoped_client_context&);
|
scoped_client_state(const scoped_client_state&);
|
||||||
scoped_client_context& operator=(const scoped_client_context&);
|
scoped_client_state& operator=(const scoped_client_state&);
|
||||||
wsrep::client_context* client_context_;
|
wsrep::client_state* client_state_;
|
||||||
D deleter_;
|
D deleter_;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -74,7 +74,7 @@ namespace wsrep
|
|||||||
class ws_handle;
|
class ws_handle;
|
||||||
class ws_meta;
|
class ws_meta;
|
||||||
class provider;
|
class provider;
|
||||||
class client_context;
|
class client_state;
|
||||||
class transaction_id;
|
class transaction_id;
|
||||||
class transaction_context;
|
class transaction_context;
|
||||||
class id;
|
class id;
|
||||||
@ -199,7 +199,7 @@ namespace wsrep
|
|||||||
*
|
*
|
||||||
* @return Pointer to Client Context.
|
* @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.
|
* Create applier context for streaming transaction.
|
||||||
@ -208,24 +208,24 @@ namespace wsrep
|
|||||||
* @param transaction_id Transaction ID of the SR transaction on the
|
* @param transaction_id Transaction ID of the SR transaction on the
|
||||||
* origin server.
|
* 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(
|
void start_streaming_applier(
|
||||||
const wsrep::id&,
|
const wsrep::id&,
|
||||||
const wsrep::transaction_id&,
|
const wsrep::transaction_id&,
|
||||||
wsrep::client_context* client_context);
|
wsrep::client_state* client_state);
|
||||||
|
|
||||||
void stop_streaming_applier(
|
void stop_streaming_applier(
|
||||||
const wsrep::id&, const wsrep::transaction_id&);
|
const wsrep::id&, const wsrep::transaction_id&);
|
||||||
/**
|
/**
|
||||||
* Return reference to streaming applier.
|
* 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;
|
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;
|
const wsrep::ws_meta&) = 0;
|
||||||
/**
|
/**
|
||||||
* Load WSRep provider.
|
* Load WSRep provider.
|
||||||
@ -333,7 +333,7 @@ namespace wsrep
|
|||||||
const wsrep::gtid& gtid,
|
const wsrep::gtid& gtid,
|
||||||
bool bypass) = 0;
|
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
|
* @todo Make this private, allow calls for provider implementations
|
||||||
* only.
|
* only.
|
||||||
* @param client_context Applier client context.
|
* @param client_state Applier client context.
|
||||||
* @param transaction_context Transaction context.
|
* @param transaction_context Transaction context.
|
||||||
* @param data Write set data
|
* @param data Write set data
|
||||||
*
|
*
|
||||||
* @return Zero on success, non-zero on failure.
|
* @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_handle& ws_handle,
|
||||||
const wsrep::ws_meta& ws_meta,
|
const wsrep::ws_meta& ws_meta,
|
||||||
const wsrep::const_buffer& data);
|
const wsrep::const_buffer& data);
|
||||||
@ -384,7 +384,7 @@ namespace wsrep
|
|||||||
* replication, false otherwise.
|
* replication, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool statement_allowed_for_streaming(
|
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;
|
const wsrep::transaction_context& transaction_context) const;
|
||||||
|
|
||||||
void debug_log_level(int level) { debug_log_level_ = level; }
|
void debug_log_level(int level) { debug_log_level_ = level; }
|
||||||
@ -435,7 +435,7 @@ namespace wsrep
|
|||||||
wsrep::condition_variable& cond_;
|
wsrep::condition_variable& cond_;
|
||||||
enum state state_;
|
enum state state_;
|
||||||
mutable std::vector<int> state_waiters_;
|
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_;
|
streaming_appliers_map streaming_appliers_;
|
||||||
wsrep::provider* provider_;
|
wsrep::provider* provider_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
@ -452,9 +452,9 @@ namespace wsrep
|
|||||||
client_deleter(wsrep::server_context& server_context)
|
client_deleter(wsrep::server_context& server_context)
|
||||||
: 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:
|
private:
|
||||||
wsrep::server_context& server_context_;
|
wsrep::server_context& server_context_;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class client_context;
|
class client_state;
|
||||||
class key;
|
class key;
|
||||||
class const_buffer;
|
class const_buffer;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace wsrep
|
|||||||
enum state state() const
|
enum state state() const
|
||||||
{ return state_; }
|
{ return state_; }
|
||||||
|
|
||||||
transaction_context(wsrep::client_context& client_context);
|
transaction_context(wsrep::client_state& client_state);
|
||||||
~transaction_context();
|
~transaction_context();
|
||||||
// Accessors
|
// Accessors
|
||||||
wsrep::transaction_id id() const
|
wsrep::transaction_id id() const
|
||||||
@ -136,7 +136,7 @@ namespace wsrep
|
|||||||
void debug_log_state(const char*) const;
|
void debug_log_state(const char*) const;
|
||||||
|
|
||||||
wsrep::provider& provider_;
|
wsrep::provider& provider_;
|
||||||
wsrep::client_context& client_context_;
|
wsrep::client_state& client_state_;
|
||||||
wsrep::transaction_id id_;
|
wsrep::transaction_id id_;
|
||||||
enum state state_;
|
enum state state_;
|
||||||
std::vector<enum state> state_hist_;
|
std::vector<enum state> state_hist_;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
add_library(wsrep-lib
|
add_library(wsrep-lib
|
||||||
client_context.cpp
|
client_state.cpp
|
||||||
id.cpp
|
id.cpp
|
||||||
logger.cpp
|
logger.cpp
|
||||||
provider.cpp
|
provider.cpp
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
#include "wsrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
#include "wsrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
|
|
||||||
@ -10,12 +10,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
wsrep::provider& wsrep::client_context::provider() const
|
wsrep::provider& wsrep::client_state::provider() const
|
||||||
{
|
{
|
||||||
return server_context_.provider();
|
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_);
|
assert(wsrep::this_thread::get_id() == thread_id_);
|
||||||
if (current_error_ != wsrep::e_success &&
|
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_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
debug_log_state("before_command: enter");
|
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)
|
else if (transaction_.state() == wsrep::transaction_context::s_aborted)
|
||||||
{
|
{
|
||||||
// Transaction was rolled back either just before sending result
|
// 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.
|
// Clean up the transaction and return error.
|
||||||
override_error(wsrep::e_deadlock_error);
|
override_error(wsrep::e_deadlock_error);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -86,7 +86,7 @@ int wsrep::client_context::before_command()
|
|||||||
return 0;
|
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_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
debug_log_state("after_command_before_result: enter");
|
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");
|
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_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
debug_log_state("after_command_after_result_enter");
|
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");
|
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_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
debug_log_state("before_statement: enter");
|
debug_log_state("before_statement: enter");
|
||||||
@ -156,8 +156,8 @@ int wsrep::client_context::before_statement()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum wsrep::client_context::after_statement_result
|
enum wsrep::client_state::after_statement_result
|
||||||
wsrep::client_context::after_statement()
|
wsrep::client_state::after_statement()
|
||||||
{
|
{
|
||||||
// wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
// wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
debug_log_state("after_statement: enter");
|
debug_log_state("after_statement: enter");
|
||||||
@ -187,20 +187,20 @@ wsrep::client_context::after_statement()
|
|||||||
|
|
||||||
// Private
|
// 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)
|
if (debug_log_level() >= 1)
|
||||||
{
|
{
|
||||||
wsrep::log_debug() << "client_context: " << context
|
wsrep::log_debug() << "client_state: " << context
|
||||||
<< ": server: " << server_context_.name()
|
<< ": server: " << server_context_.name()
|
||||||
<< " client: " << id_.get()
|
<< " client: " << id_.get()
|
||||||
<< " current_error: " << current_error_;
|
<< " current_error: " << current_error_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsrep::client_context::state(
|
void wsrep::client_state::state(
|
||||||
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
|
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(wsrep::this_thread::get_id() == thread_id_);
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
@ -219,7 +219,7 @@ void wsrep::client_context::state(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "client_context: Unallowed state transition: "
|
os << "client_state: Unallowed state transition: "
|
||||||
<< state_ << " -> " << state;
|
<< state_ << " -> " << state;
|
||||||
throw wsrep::runtime_error(os.str());
|
throw wsrep::runtime_error(os.str());
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "wsrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
#include "wsrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "wsrep/view.hpp"
|
#include "wsrep/view.hpp"
|
||||||
#include "wsrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
@ -118,14 +118,14 @@ void wsrep::server_context::on_sync()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int wsrep::server_context::on_apply(
|
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_handle& ws_handle,
|
||||||
const wsrep::ws_meta& ws_meta,
|
const wsrep::ws_meta& ws_meta,
|
||||||
const wsrep::const_buffer& data)
|
const wsrep::const_buffer& data)
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
const wsrep::transaction_context& txc(client_context.transaction());
|
const wsrep::transaction_context& txc(client_state.transaction());
|
||||||
assert(client_context.mode() == wsrep::client_context::m_high_priority);
|
assert(client_state.mode() == wsrep::client_state::m_high_priority);
|
||||||
|
|
||||||
bool not_replaying(txc.state() !=
|
bool not_replaying(txc.state() !=
|
||||||
wsrep::transaction_context::s_replaying);
|
wsrep::transaction_context::s_replaying);
|
||||||
@ -135,35 +135,35 @@ int wsrep::server_context::on_apply(
|
|||||||
{
|
{
|
||||||
if (not_replaying)
|
if (not_replaying)
|
||||||
{
|
{
|
||||||
client_context.before_command();
|
client_state.before_command();
|
||||||
client_context.before_statement();
|
client_state.before_statement();
|
||||||
assert(txc.active() == false);
|
assert(txc.active() == false);
|
||||||
client_context.start_transaction(ws_handle, ws_meta);
|
client_state.start_transaction(ws_handle, ws_meta);
|
||||||
}
|
}
|
||||||
else
|
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;
|
ret = 1;
|
||||||
}
|
}
|
||||||
else if (client_context.commit())
|
else if (client_state.commit())
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
client_context.rollback();
|
client_state.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not_replaying)
|
if (not_replaying)
|
||||||
{
|
{
|
||||||
client_context.after_statement();
|
client_state.after_statement();
|
||||||
client_context.after_command_before_result();
|
client_state.after_command_before_result();
|
||||||
client_context.after_command_after_result();
|
client_state.after_command_after_result();
|
||||||
}
|
}
|
||||||
assert(ret ||
|
assert(ret ||
|
||||||
txc.state() == wsrep::transaction_context::s_committed);
|
txc.state() == wsrep::transaction_context::s_committed);
|
||||||
@ -173,7 +173,7 @@ int wsrep::server_context::on_apply(
|
|||||||
assert(not_replaying);
|
assert(not_replaying);
|
||||||
assert(find_streaming_applier(
|
assert(find_streaming_applier(
|
||||||
ws_meta.server_id(), ws_meta.transaction_id()) == 0);
|
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(
|
start_streaming_applier(
|
||||||
ws_meta.server_id(), ws_meta.transaction_id(), sac);
|
ws_meta.server_id(), ws_meta.transaction_id(), sac);
|
||||||
sac->start_transaction(ws_handle, ws_meta);
|
sac->start_transaction(ws_handle, ws_meta);
|
||||||
@ -183,7 +183,7 @@ int wsrep::server_context::on_apply(
|
|||||||
// introduce a virtual method call which takes
|
// introduce a virtual method call which takes
|
||||||
// both original and sac client contexts as argument
|
// both original and sac client contexts as argument
|
||||||
// and a functor which does the applying.
|
// 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_command();
|
||||||
sac->before_statement();
|
sac->before_statement();
|
||||||
sac->apply(data);
|
sac->apply(data);
|
||||||
@ -191,11 +191,11 @@ int wsrep::server_context::on_apply(
|
|||||||
sac->after_command_before_result();
|
sac->after_command_before_result();
|
||||||
sac->after_command_after_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)
|
else if (ws_meta.flags() == 0)
|
||||||
{
|
{
|
||||||
wsrep::client_context* sac(
|
wsrep::client_state* sac(
|
||||||
find_streaming_applier(
|
find_streaming_applier(
|
||||||
ws_meta.server_id(), ws_meta.transaction_id()));
|
ws_meta.server_id(), ws_meta.transaction_id()));
|
||||||
if (sac == 0)
|
if (sac == 0)
|
||||||
@ -211,7 +211,7 @@ int wsrep::server_context::on_apply(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsrep::client_context_switch(client_context, *sac);
|
wsrep::client_state_switch(client_state, *sac);
|
||||||
sac->before_command();
|
sac->before_command();
|
||||||
sac->before_statement();
|
sac->before_statement();
|
||||||
ret = sac->apply(data);
|
ret = sac->apply(data);
|
||||||
@ -219,13 +219,13 @@ int wsrep::server_context::on_apply(
|
|||||||
sac->after_command_before_result();
|
sac->after_command_before_result();
|
||||||
sac->after_command_after_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()))
|
else if (commits_transaction(ws_meta.flags()))
|
||||||
{
|
{
|
||||||
if (not_replaying)
|
if (not_replaying)
|
||||||
{
|
{
|
||||||
wsrep::client_context* sac(
|
wsrep::client_state* sac(
|
||||||
find_streaming_applier(
|
find_streaming_applier(
|
||||||
ws_meta.server_id(), ws_meta.transaction_id()));
|
ws_meta.server_id(), ws_meta.transaction_id()));
|
||||||
assert(sac);
|
assert(sac);
|
||||||
@ -242,7 +242,7 @@ int wsrep::server_context::on_apply(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsrep::client_context_switch(client_context, *sac);
|
wsrep::client_state_switch(client_state, *sac);
|
||||||
sac->before_command();
|
sac->before_command();
|
||||||
sac->before_statement();
|
sac->before_statement();
|
||||||
ret = sac->commit();
|
ret = sac->commit();
|
||||||
@ -251,14 +251,14 @@ int wsrep::server_context::on_apply(
|
|||||||
sac->after_command_after_result();
|
sac->after_command_after_result();
|
||||||
stop_streaming_applier(
|
stop_streaming_applier(
|
||||||
ws_meta.server_id(), ws_meta.transaction_id());
|
ws_meta.server_id(), ws_meta.transaction_id());
|
||||||
release_client_context(sac);
|
release_client_state(sac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = client_context.start_replaying(ws_meta) ||
|
ret = client_state.start_replaying(ws_meta) ||
|
||||||
client_context.apply(wsrep::const_buffer()) ||
|
client_state.apply(wsrep::const_buffer()) ||
|
||||||
client_context.commit();
|
client_state.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -274,7 +274,7 @@ int wsrep::server_context::on_apply(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wsrep::server_context::statement_allowed_for_streaming(
|
bool wsrep::server_context::statement_allowed_for_streaming(
|
||||||
const wsrep::client_context&,
|
const wsrep::client_state&,
|
||||||
const wsrep::transaction_context&) const
|
const wsrep::transaction_context&) const
|
||||||
{
|
{
|
||||||
/* Streaming not implemented yet. */
|
/* Streaming not implemented yet. */
|
||||||
@ -284,14 +284,14 @@ bool wsrep::server_context::statement_allowed_for_streaming(
|
|||||||
void wsrep::server_context::start_streaming_applier(
|
void wsrep::server_context::start_streaming_applier(
|
||||||
const wsrep::id& server_id,
|
const wsrep::id& server_id,
|
||||||
const wsrep::transaction_id& transaction_id,
|
const wsrep::transaction_id& transaction_id,
|
||||||
wsrep::client_context* client_context)
|
wsrep::client_state* client_state)
|
||||||
{
|
{
|
||||||
if (streaming_appliers_.insert(
|
if (streaming_appliers_.insert(
|
||||||
std::make_pair(std::make_pair(server_id, transaction_id),
|
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";
|
wsrep::log_error() << "Could not insert streaming applier";
|
||||||
delete client_context;
|
delete client_state;
|
||||||
throw wsrep::fatal_error();
|
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::id& server_id,
|
||||||
const wsrep::transaction_id& transaction_id) const
|
const wsrep::transaction_id& transaction_id) const
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace
|
|||||||
wsrep::server_context::rm_sync)
|
wsrep::server_context::rm_sync)
|
||||||
, cc(sc,
|
, cc(sc,
|
||||||
wsrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
wsrep::client_context::m_applier,
|
wsrep::client_state::m_applier,
|
||||||
false)
|
false)
|
||||||
, ws_handle(1, (void*)1)
|
, ws_handle(1, (void*)1)
|
||||||
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
||||||
@ -27,7 +27,7 @@ namespace
|
|||||||
cc.start_transaction(ws_handle, ws_meta);
|
cc.start_transaction(ws_handle, ws_meta);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
wsrep::ws_handle ws_handle;
|
wsrep::ws_handle ws_handle;
|
||||||
wsrep::ws_meta ws_meta;
|
wsrep::ws_meta ws_meta;
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "wsrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
#include "wsrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "wsrep/key.hpp"
|
#include "wsrep/key.hpp"
|
||||||
#include "wsrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define WSREP_TC_LOG_DEBUG(level, msg) \
|
#define WSREP_TC_LOG_DEBUG(level, msg) \
|
||||||
do { \
|
do { \
|
||||||
if (client_context_.debug_log_level() < level) \
|
if (client_state_.debug_log_level() < level) \
|
||||||
{ } \
|
{ } \
|
||||||
else wsrep::log_debug() << msg; \
|
else wsrep::log_debug() << msg; \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -22,9 +22,9 @@
|
|||||||
// Public
|
// Public
|
||||||
|
|
||||||
wsrep::transaction_context::transaction_context(
|
wsrep::transaction_context::transaction_context(
|
||||||
wsrep::client_context& client_context)
|
wsrep::client_state& client_state)
|
||||||
: provider_(client_context.provider())
|
: provider_(client_state.provider())
|
||||||
, client_context_(client_context)
|
, client_state_(client_state)
|
||||||
, id_(transaction_id::invalid())
|
, id_(transaction_id::invalid())
|
||||||
, state_(s_executing)
|
, state_(s_executing)
|
||||||
, state_hist_()
|
, state_hist_()
|
||||||
@ -52,12 +52,12 @@ int wsrep::transaction_context::start_transaction(
|
|||||||
state_hist_.clear();
|
state_hist_.clear();
|
||||||
ws_handle_ = wsrep::ws_handle(id);
|
ws_handle_ = wsrep::ws_handle(id);
|
||||||
flags_ |= wsrep::provider::flag::start_transaction;
|
flags_ |= wsrep::provider::flag::start_transaction;
|
||||||
switch (client_context_.mode())
|
switch (client_state_.mode())
|
||||||
{
|
{
|
||||||
case wsrep::client_context::m_local:
|
case wsrep::client_state::m_local:
|
||||||
case wsrep::client_context::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
return 0;
|
return 0;
|
||||||
case wsrep::client_context::m_replicating:
|
case wsrep::client_state::m_replicating:
|
||||||
return provider_.start_transaction(ws_handle_);
|
return provider_.start_transaction(ws_handle_);
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -72,7 +72,7 @@ int wsrep::transaction_context::start_transaction(
|
|||||||
assert(ws_meta.flags());
|
assert(ws_meta.flags());
|
||||||
assert(active() == false);
|
assert(active() == false);
|
||||||
id_ = ws_meta.transaction_id();
|
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_ = s_executing;
|
||||||
state_hist_.clear();
|
state_hist_.clear();
|
||||||
ws_handle_ = ws_handle;
|
ws_handle_ = ws_handle;
|
||||||
@ -86,7 +86,7 @@ int wsrep::transaction_context::start_replaying(const wsrep::ws_meta& ws_meta)
|
|||||||
ws_meta_ = ws_meta;
|
ws_meta_ = ws_meta;
|
||||||
assert(ws_meta_.flags() & wsrep::provider::flag::commit);
|
assert(ws_meta_.flags() & wsrep::provider::flag::commit);
|
||||||
assert(active());
|
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(state() == s_replaying);
|
||||||
assert(ws_meta_.seqno().nil() == false);
|
assert(ws_meta_.seqno().nil() == false);
|
||||||
certified_ = true;
|
certified_ = true;
|
||||||
@ -107,7 +107,7 @@ int wsrep::transaction_context::append_data(const wsrep::const_buffer& data)
|
|||||||
|
|
||||||
int wsrep::transaction_context::after_row()
|
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)
|
if (streaming_context_.fragment_size() > 0)
|
||||||
{
|
{
|
||||||
switch (streaming_context_.fragment_unit())
|
switch (streaming_context_.fragment_unit())
|
||||||
@ -122,7 +122,7 @@ int wsrep::transaction_context::after_row()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case streaming_context::bytes:
|
case streaming_context::bytes:
|
||||||
if (client_context_.bytes_generated() >=
|
if (client_state_.bytes_generated() >=
|
||||||
streaming_context_.bytes_certified()
|
streaming_context_.bytes_certified()
|
||||||
+ streaming_context_.fragment_size())
|
+ streaming_context_.fragment_size())
|
||||||
{
|
{
|
||||||
@ -148,41 +148,41 @@ int wsrep::transaction_context::before_prepare(
|
|||||||
|
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
assert(client_context_.mode() == wsrep::client_context::m_replicating);
|
assert(client_state_.mode() == wsrep::client_state::m_replicating);
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state(lock, s_preparing);
|
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())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
client_context_.debug_crash(
|
client_state_.debug_crash(
|
||||||
"crash_last_fragment_commit_before_fragment_removal");
|
"crash_last_fragment_commit_before_fragment_removal");
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
if (client_context_.server_context().statement_allowed_for_streaming(
|
if (client_state_.server_context().statement_allowed_for_streaming(
|
||||||
client_context_, *this))
|
client_state_, *this))
|
||||||
{
|
{
|
||||||
client_context_.override_error(wsrep::e_error_during_commit);
|
client_state_.override_error(wsrep::e_error_during_commit);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client_context_.remove_fragments();
|
client_state_.remove_fragments();
|
||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
client_context_.debug_crash(
|
client_state_.debug_crash(
|
||||||
"crash_last_fragment_commit_after_fragment_removal");
|
"crash_last_fragment_commit_after_fragment_removal");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_local:
|
case wsrep::client_state::m_local:
|
||||||
case wsrep::client_context::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
client_context_.remove_fragments();
|
client_state_.remove_fragments();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -204,22 +204,22 @@ int wsrep::transaction_context::after_prepare(
|
|||||||
assert(state() == s_preparing || state() == s_must_abort);
|
assert(state() == s_preparing || state() == s_must_abort);
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
assert(client_context_.mode() == wsrep::client_context::m_replicating);
|
assert(client_state_.mode() == wsrep::client_state::m_replicating);
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
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);
|
ret = certify_commit(lock);
|
||||||
assert((ret == 0 && state() == s_committing) ||
|
assert((ret == 0 && state() == s_committing) ||
|
||||||
(state() == s_must_abort ||
|
(state() == s_must_abort ||
|
||||||
state() == s_must_replay ||
|
state() == s_must_replay ||
|
||||||
state() == s_cert_failed));
|
state() == s_cert_failed));
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_local:
|
case wsrep::client_state::m_local:
|
||||||
case wsrep::client_context::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
state(lock, s_certifying);
|
state(lock, s_certifying);
|
||||||
state(lock, s_committing);
|
state(lock, s_committing);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -236,9 +236,9 @@ int wsrep::transaction_context::before_commit()
|
|||||||
{
|
{
|
||||||
int ret(1);
|
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");
|
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 ||
|
assert(state() == s_executing ||
|
||||||
state() == s_committing ||
|
state() == s_committing ||
|
||||||
state() == s_must_abort ||
|
state() == s_must_abort ||
|
||||||
@ -246,18 +246,18 @@ int wsrep::transaction_context::before_commit()
|
|||||||
assert((state() != s_committing && state() != s_replaying) ||
|
assert((state() != s_committing && state() != s_replaying) ||
|
||||||
certified());
|
certified());
|
||||||
|
|
||||||
switch (client_context_.mode())
|
switch (client_state_.mode())
|
||||||
{
|
{
|
||||||
case wsrep::client_context::m_local:
|
case wsrep::client_state::m_local:
|
||||||
if (ordered())
|
if (ordered())
|
||||||
{
|
{
|
||||||
ret = provider_.commit_order_enter(ws_handle_, ws_meta_);
|
ret = provider_.commit_order_enter(ws_handle_, ws_meta_);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_replicating:
|
case wsrep::client_state::m_replicating:
|
||||||
if (state() == s_executing)
|
if (state() == s_executing)
|
||||||
{
|
{
|
||||||
assert(client_context_.do_2pc() == false);
|
assert(client_state_.do_2pc() == false);
|
||||||
ret = before_prepare(lock) || after_prepare(lock);
|
ret = before_prepare(lock) || after_prepare(lock);
|
||||||
assert((ret == 0 && state() == s_committing)
|
assert((ret == 0 && state() == s_committing)
|
||||||
||
|
||
|
||||||
@ -274,7 +274,7 @@ int wsrep::transaction_context::before_commit()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -309,10 +309,10 @@ int wsrep::transaction_context::before_commit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
assert(certified());
|
assert(certified());
|
||||||
assert(ordered());
|
assert(ordered());
|
||||||
if (client_context_.do_2pc() == false)
|
if (client_state_.do_2pc() == false)
|
||||||
{
|
{
|
||||||
ret = before_prepare(lock) || after_prepare(lock);
|
ret = before_prepare(lock) || after_prepare(lock);
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ int wsrep::transaction_context::before_commit()
|
|||||||
|
|
||||||
int wsrep::transaction_context::ordered_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");
|
debug_log_state("ordered_commit_enter");
|
||||||
assert(state() == s_committing);
|
assert(state() == s_committing);
|
||||||
assert(ordered());
|
assert(ordered());
|
||||||
@ -352,26 +352,26 @@ int wsrep::transaction_context::after_commit()
|
|||||||
{
|
{
|
||||||
int ret(0);
|
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");
|
debug_log_state("after_commit_enter");
|
||||||
assert(state() == s_ordered_commit);
|
assert(state() == s_ordered_commit);
|
||||||
|
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
assert(client_context_.mode() == wsrep::client_context::m_replicating ||
|
assert(client_state_.mode() == wsrep::client_state::m_replicating ||
|
||||||
client_context_.mode() == wsrep::client_context::m_high_priority);
|
client_state_.mode() == wsrep::client_state::m_high_priority);
|
||||||
clear_fragments();
|
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
|
// Nothing to do
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_replicating:
|
case wsrep::client_state::m_replicating:
|
||||||
ret = provider_.release(ws_handle_);
|
ret = provider_.release(ws_handle_);
|
||||||
break;
|
break;
|
||||||
case wsrep::client_context::m_high_priority:
|
case wsrep::client_state::m_high_priority:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -385,7 +385,7 @@ int wsrep::transaction_context::after_commit()
|
|||||||
|
|
||||||
int wsrep::transaction_context::before_rollback()
|
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");
|
debug_log_state("before_rollback_enter");
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_must_abort ||
|
state() == s_must_abort ||
|
||||||
@ -442,7 +442,7 @@ int wsrep::transaction_context::before_rollback()
|
|||||||
|
|
||||||
int wsrep::transaction_context::after_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");
|
debug_log_state("after_rollback_enter");
|
||||||
assert(state() == s_aborting ||
|
assert(state() == s_aborting ||
|
||||||
state() == s_must_replay);
|
state() == s_must_replay);
|
||||||
@ -465,7 +465,7 @@ int wsrep::transaction_context::after_rollback()
|
|||||||
int wsrep::transaction_context::after_statement()
|
int wsrep::transaction_context::after_statement()
|
||||||
{
|
{
|
||||||
int ret(0);
|
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");
|
debug_log_state("after_statement_enter");
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_committed ||
|
state() == s_committed ||
|
||||||
@ -496,9 +496,9 @@ int wsrep::transaction_context::after_statement()
|
|||||||
break;
|
break;
|
||||||
case s_must_abort:
|
case s_must_abort:
|
||||||
case s_cert_failed:
|
case s_cert_failed:
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
ret = client_context_.rollback();
|
ret = client_state_.rollback();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
if (state() != s_must_replay)
|
if (state() != s_must_replay)
|
||||||
{
|
{
|
||||||
@ -510,19 +510,19 @@ int wsrep::transaction_context::after_statement()
|
|||||||
{
|
{
|
||||||
state(lock, s_replaying);
|
state(lock, s_replaying);
|
||||||
lock.unlock();
|
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)
|
switch (replay_ret)
|
||||||
{
|
{
|
||||||
case wsrep::provider::success:
|
case wsrep::provider::success:
|
||||||
provider_.release(ws_handle_);
|
provider_.release(ws_handle_);
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_certification_failed:
|
case wsrep::provider::error_certification_failed:
|
||||||
client_context_.override_error(
|
client_state_.override_error(
|
||||||
wsrep::e_deadlock_error);
|
wsrep::e_deadlock_error);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
client_context_.emergency_shutdown();
|
client_state_.emergency_shutdown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
@ -593,7 +593,7 @@ bool wsrep::transaction_context::bf_abort(
|
|||||||
{
|
{
|
||||||
wsrep::seqno victim_seqno;
|
wsrep::seqno victim_seqno;
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
status(client_context_.provider().bf_abort(
|
status(client_state_.provider().bf_abort(
|
||||||
bf_seqno, id_.get(), victim_seqno));
|
bf_seqno, id_.get(), victim_seqno));
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@ -624,9 +624,9 @@ bool wsrep::transaction_context::bf_abort(
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
bf_abort_client_state_ = client_context_.state();
|
bf_abort_client_state_ = client_state_.state();
|
||||||
if (client_context_.state() == wsrep::client_context::s_idle &&
|
if (client_state_.state() == wsrep::client_state::s_idle &&
|
||||||
client_context_.server_context().rollback_mode() ==
|
client_state_.server_context().rollback_mode() ==
|
||||||
wsrep::server_context::rm_sync)
|
wsrep::server_context::rm_sync)
|
||||||
{
|
{
|
||||||
// We need to change the state to aborting under the
|
// We need to change the state to aborting under the
|
||||||
@ -636,7 +636,7 @@ bool wsrep::transaction_context::bf_abort(
|
|||||||
// rollbacker gets control.
|
// rollbacker gets control.
|
||||||
state(lock, wsrep::transaction_context::s_aborting);
|
state(lock, wsrep::transaction_context::s_aborting);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
client_context_.server_context().background_rollback(client_context_);
|
client_state_.server_context().background_rollback(client_state_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -650,9 +650,9 @@ void wsrep::transaction_context::state(
|
|||||||
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
|
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
|
||||||
enum wsrep::transaction_context::state next_state)
|
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()
|
<< " txc: " << id().get()
|
||||||
<< " state: " << to_string(state_)
|
<< " state: " << to_string(state_)
|
||||||
<< " -> " << to_string(next_state);
|
<< " -> " << to_string(next_state);
|
||||||
@ -694,13 +694,13 @@ int wsrep::transaction_context::certify_fragment(
|
|||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
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);
|
assert(streaming_context_.rolled_back() == false);
|
||||||
|
|
||||||
client_context_.wait_for_replayers(lock);
|
client_state_.wait_for_replayers(lock);
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ int wsrep::transaction_context::certify_fragment(
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
wsrep::mutable_buffer data;
|
wsrep::mutable_buffer data;
|
||||||
if (client_context_.prepare_fragment_for_replication(*this, data))
|
if (client_state_.prepare_fragment_for_replication(*this, data))
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
@ -719,34 +719,34 @@ int wsrep::transaction_context::certify_fragment(
|
|||||||
// Client context to store fragment in separate transaction
|
// Client context to store fragment in separate transaction
|
||||||
// Switch temporarily to sr_transaction_context, switch back
|
// Switch temporarily to sr_transaction_context, switch back
|
||||||
// to original when this goes out of scope
|
// to original when this goes out of scope
|
||||||
// std::auto_ptr<wsrep::client_context> sr_client_context(
|
// std::auto_ptr<wsrep::client_state> sr_client_state(
|
||||||
// client_context_.server_context().local_client_context());
|
// client_state_.server_context().local_client_state());
|
||||||
wsrep::scoped_client_context<wsrep::client_deleter> sr_client_context_scope(
|
wsrep::scoped_client_state<wsrep::client_deleter> sr_client_state_scope(
|
||||||
client_context_.server_context().local_client_context(),
|
client_state_.server_context().local_client_state(),
|
||||||
wsrep::client_deleter(client_context_.server_context()));
|
wsrep::client_deleter(client_state_.server_context()));
|
||||||
wsrep::client_context& sr_client_context(
|
wsrep::client_state& sr_client_state(
|
||||||
sr_client_context_scope.client_context());
|
sr_client_state_scope.client_state());
|
||||||
wsrep::client_context_switch client_context_switch(
|
wsrep::client_state_switch client_state_switch(
|
||||||
client_context_,
|
client_state_,
|
||||||
sr_client_context);
|
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(
|
wsrep::transaction_context& sr_transaction_context(
|
||||||
sr_client_context.transaction_);
|
sr_client_state.transaction_);
|
||||||
sr_transaction_context.state(sr_lock, s_certifying);
|
sr_transaction_context.state(sr_lock, s_certifying);
|
||||||
sr_lock.unlock();
|
sr_lock.unlock();
|
||||||
if (sr_client_context.append_fragment(
|
if (sr_client_state.append_fragment(
|
||||||
sr_transaction_context, flags_,
|
sr_transaction_context, flags_,
|
||||||
wsrep::const_buffer(data.data(), data.size())))
|
wsrep::const_buffer(data.data(), data.size())))
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
state(lock, s_must_abort);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum wsrep::provider::status
|
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_,
|
sr_transaction_context.ws_handle_,
|
||||||
flags_,
|
flags_,
|
||||||
sr_transaction_context.ws_meta_));
|
sr_transaction_context.ws_meta_));
|
||||||
@ -760,7 +760,7 @@ int wsrep::transaction_context::certify_fragment(
|
|||||||
sr_transaction_context.certified_ = true;
|
sr_transaction_context.certified_ = true;
|
||||||
sr_transaction_context.state(sr_lock, s_committing);
|
sr_transaction_context.state(sr_lock, s_committing);
|
||||||
sr_lock.unlock();
|
sr_lock.unlock();
|
||||||
if (sr_client_context.commit())
|
if (sr_client_state.commit())
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ int wsrep::transaction_context::certify_fragment(
|
|||||||
sr_lock.lock();
|
sr_lock.lock();
|
||||||
sr_transaction_context.state(sr_lock, s_must_abort);
|
sr_transaction_context.state(sr_lock, s_must_abort);
|
||||||
sr_lock.unlock();
|
sr_lock.unlock();
|
||||||
sr_client_context.rollback();
|
sr_client_state.rollback();
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -791,13 +791,13 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
assert(active());
|
assert(active());
|
||||||
client_context_.wait_for_replayers(lock);
|
client_state_.wait_for_replayers(lock);
|
||||||
|
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
|
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,30 +807,30 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
|
|
||||||
lock.unlock();
|
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()
|
// Note: Error must be set by prepare_data_for_replication()
|
||||||
lock.lock();
|
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);
|
state(lock, s_must_abort);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client_context_.interrupted())
|
if (client_state_.interrupted())
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
client_context_.override_error(wsrep::e_interrupted_error);
|
client_state_.override_error(wsrep::e_interrupted_error);
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_context_.debug_sync("wsrep_before_certification");
|
client_state_.debug_sync("wsrep_before_certification");
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
cert_ret(provider_.certify(client_context_.id().get(),
|
cert_ret(provider_.certify(client_state_.id().get(),
|
||||||
ws_handle_,
|
ws_handle_,
|
||||||
flags(),
|
flags(),
|
||||||
ws_meta_));
|
ws_meta_));
|
||||||
client_context_.debug_sync("wsrep_after_certification");
|
client_state_.debug_sync("wsrep_after_certification");
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
||||||
@ -852,7 +852,7 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
// We got BF aborted after succesful certification
|
// We got BF aborted after succesful certification
|
||||||
// and before acquiring client context lock. This means that
|
// and before acquiring client context lock. This means that
|
||||||
// the trasaction must be replayed.
|
// the trasaction must be replayed.
|
||||||
client_context_.will_replay(*this);
|
client_state_.will_replay(*this);
|
||||||
state(lock, s_must_replay);
|
state(lock, s_must_replay);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -863,14 +863,14 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
case wsrep::provider::error_warning:
|
case wsrep::provider::error_warning:
|
||||||
assert(ordered() == false);
|
assert(ordered() == false);
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(wsrep::e_error_during_commit);
|
client_state_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_transaction_missing:
|
case wsrep::provider::error_transaction_missing:
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
// The execution should never reach this point if the
|
// The execution should never reach this point if the
|
||||||
// transaction has not generated any keys or data.
|
// transaction has not generated any keys or data.
|
||||||
wsrep::log_warning() << "Transaction was missing in provider";
|
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;
|
break;
|
||||||
case wsrep::provider::error_bf_abort:
|
case wsrep::provider::error_bf_abort:
|
||||||
// Transaction was replicated succesfully and it was either
|
// 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
|
// yet known. Therefore the transaction must roll back
|
||||||
// and go through replay either to replay and commit the whole
|
// and go through replay either to replay and commit the whole
|
||||||
// transaction or to determine failed certification status.
|
// transaction or to determine failed certification status.
|
||||||
client_context_.will_replay(*this);
|
client_state_.will_replay(*this);
|
||||||
if (state() != s_must_abort)
|
if (state() != s_must_abort)
|
||||||
{
|
{
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
@ -887,11 +887,11 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
break;
|
break;
|
||||||
case wsrep::provider::error_certification_failed:
|
case wsrep::provider::error_certification_failed:
|
||||||
state(lock, s_cert_failed);
|
state(lock, s_cert_failed);
|
||||||
client_context_.override_error(wsrep::e_deadlock_error);
|
client_state_.override_error(wsrep::e_deadlock_error);
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_size_exceeded:
|
case wsrep::provider::error_size_exceeded:
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(wsrep::e_error_during_commit);
|
client_state_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_connection_failed:
|
case wsrep::provider::error_connection_failed:
|
||||||
case wsrep::provider::error_provider_failed:
|
case wsrep::provider::error_provider_failed:
|
||||||
@ -901,16 +901,16 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
{
|
{
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
}
|
}
|
||||||
client_context_.override_error(wsrep::e_error_during_commit);
|
client_state_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_fatal:
|
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);
|
state(lock, s_must_abort);
|
||||||
client_context_.emergency_shutdown();
|
client_state_.emergency_shutdown();
|
||||||
break;
|
break;
|
||||||
case wsrep::provider::error_not_implemented:
|
case wsrep::provider::error_not_implemented:
|
||||||
case wsrep::provider::error_not_allowed:
|
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);
|
state(lock, s_must_abort);
|
||||||
wsrep::log_warning() << "Certification operation was not allowed: "
|
wsrep::log_warning() << "Certification operation was not allowed: "
|
||||||
<< "id: " << id().get()
|
<< "id: " << id().get()
|
||||||
@ -918,7 +918,7 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(wsrep::e_error_during_commit);
|
client_state_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,10 +928,10 @@ int wsrep::transaction_context::certify_commit(
|
|||||||
void wsrep::transaction_context::streaming_rollback()
|
void wsrep::transaction_context::streaming_rollback()
|
||||||
{
|
{
|
||||||
assert(streaming_context_.rolled_back() == false);
|
assert(streaming_context_.rolled_back() == false);
|
||||||
wsrep::client_context* sac(
|
wsrep::client_state* sac(
|
||||||
client_context_.server_context().streaming_applier_client_context());
|
client_state_.server_context().streaming_applier_client_state());
|
||||||
client_context_.server_context().start_streaming_applier(
|
client_state_.server_context().start_streaming_applier(
|
||||||
client_context_.server_context().id(), id(), sac);
|
client_state_.server_context().id(), id(), sac);
|
||||||
sac->adopt_transaction(*this);
|
sac->adopt_transaction(*this);
|
||||||
streaming_context_.cleanup();
|
streaming_context_.cleanup();
|
||||||
// Replicate rollback fragment
|
// Replicate rollback fragment
|
||||||
@ -963,10 +963,10 @@ void wsrep::transaction_context::debug_log_state(
|
|||||||
{
|
{
|
||||||
WSREP_TC_LOG_DEBUG(
|
WSREP_TC_LOG_DEBUG(
|
||||||
1, context
|
1, context
|
||||||
<< ": server: " << client_context_.server_context().name()
|
<< ": server: " << client_state_.server_context().name()
|
||||||
<< " client: " << client_context_.id().get()
|
<< " client: " << client_state_.id().get()
|
||||||
<< " trx: " << int64_t(id_.get())
|
<< " trx: " << int64_t(id_.get())
|
||||||
<< " state: " << wsrep::to_string(state_)
|
<< " state: " << wsrep::to_string(state_)
|
||||||
<< " error: "
|
<< " error: "
|
||||||
<< wsrep::to_string(client_context_.current_error()));
|
<< wsrep::to_string(client_state_.current_error()));
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "wsrep_provider_v26.hpp"
|
#include "wsrep_provider_v26.hpp"
|
||||||
|
|
||||||
#include "wsrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
#include "wsrep/view.hpp"
|
#include "wsrep/view.hpp"
|
||||||
#include "wsrep/exception.hpp"
|
#include "wsrep/exception.hpp"
|
||||||
|
|
||||||
@ -309,10 +309,10 @@ namespace
|
|||||||
{
|
{
|
||||||
wsrep_cb_status_t ret(WSREP_CB_SUCCESS);
|
wsrep_cb_status_t ret(WSREP_CB_SUCCESS);
|
||||||
|
|
||||||
wsrep::client_context* client_context(
|
wsrep::client_state* client_state(
|
||||||
reinterpret_cast<wsrep::client_context*>(ctx));
|
reinterpret_cast<wsrep::client_state*>(ctx));
|
||||||
assert(client_context);
|
assert(client_state);
|
||||||
assert(client_context->mode() == wsrep::client_context::m_high_priority);
|
assert(client_state->mode() == wsrep::client_state::m_high_priority);
|
||||||
|
|
||||||
wsrep::const_buffer data(buf->ptr, buf->len);
|
wsrep::const_buffer data(buf->ptr, buf->len);
|
||||||
wsrep::ws_handle ws_handle(wsh->trx_id, wsh->opaque);
|
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)),
|
meta->stid.conn), wsrep::seqno(seqno_from_native(meta->depends_on)),
|
||||||
map_flags_from_native(flags));
|
map_flags_from_native(flags));
|
||||||
if (ret == WSREP_CB_SUCCESS &&
|
if (ret == WSREP_CB_SUCCESS &&
|
||||||
client_context->server_context().on_apply(
|
client_state->server_context().on_apply(
|
||||||
*client_context, ws_handle, ws_meta, data))
|
*client_state, ws_handle, ws_meta, data))
|
||||||
{
|
{
|
||||||
ret = WSREP_CB_FAILURE;
|
ret = WSREP_CB_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
add_executable(wsrep-lib_test
|
add_executable(wsrep-lib_test
|
||||||
mock_client_context.cpp
|
mock_client_state.cpp
|
||||||
test_utils.cpp
|
test_utils.cpp
|
||||||
id_test.cpp
|
id_test.cpp
|
||||||
server_context_test.cpp
|
server_context_test.cpp
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define WSREP_TEST_CLIENT_CONTEXT_FIXTURE_HPP
|
#define WSREP_TEST_CLIENT_CONTEXT_FIXTURE_HPP
|
||||||
|
|
||||||
#include "mock_server_context.hpp"
|
#include "mock_server_context.hpp"
|
||||||
#include "mock_client_context.hpp"
|
#include "mock_client_state.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
@ -18,7 +18,7 @@ namespace
|
|||||||
replicating_client_fixture_sync_rm()
|
replicating_client_fixture_sync_rm()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -28,7 +28,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ namespace
|
|||||||
replicating_client_fixture_async_rm()
|
replicating_client_fixture_async_rm()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_async)
|
: sc("s1", "s1", wsrep::server_context::rm_async)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -47,7 +47,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ namespace
|
|||||||
replicating_client_fixture_2pc()
|
replicating_client_fixture_2pc()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
sc.client_service().do_2pc_ = true;
|
sc.client_service().do_2pc_ = true;
|
||||||
@ -67,7 +67,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace
|
|||||||
replicating_client_fixture_autocommit()
|
replicating_client_fixture_autocommit()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
sc.client_service().is_autocommit_ = true;
|
sc.client_service().is_autocommit_ = true;
|
||||||
@ -87,7 +87,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ namespace
|
|||||||
wsrep::server_context::rm_async)
|
wsrep::server_context::rm_async)
|
||||||
, cc(sc, sc.client_service(),
|
, cc(sc, sc.client_service(),
|
||||||
wsrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
wsrep::client_context::m_high_priority)
|
wsrep::client_state::m_high_priority)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -115,7 +115,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.ordered() == true);
|
BOOST_REQUIRE(tc.ordered() == true);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ namespace
|
|||||||
wsrep::server_context::rm_async)
|
wsrep::server_context::rm_async)
|
||||||
, cc(sc, sc.client_service(),
|
, cc(sc, sc.client_service(),
|
||||||
wsrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
wsrep::client_context::m_high_priority)
|
wsrep::client_state::m_high_priority)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
sc.client_service().do_2pc_ = true;
|
sc.client_service().do_2pc_ = true;
|
||||||
@ -144,7 +144,7 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.ordered() == true);
|
BOOST_REQUIRE(tc.ordered() == true);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ namespace
|
|||||||
streaming_client_fixture_row()
|
streaming_client_fixture_row()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -164,7 +164,7 @@ namespace
|
|||||||
cc.enable_streaming(wsrep::streaming_context::row, 1);
|
cc.enable_streaming(wsrep::streaming_context::row, 1);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ namespace
|
|||||||
streaming_client_fixture_byte()
|
streaming_client_fixture_byte()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -184,7 +184,7 @@ namespace
|
|||||||
cc.enable_streaming(wsrep::streaming_context::bytes, 1);
|
cc.enable_streaming(wsrep::streaming_context::bytes, 1);
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ namespace
|
|||||||
streaming_client_fixture_statement()
|
streaming_client_fixture_statement()
|
||||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
, cc(sc, sc.client_service(), wsrep::client_id(1),
|
||||||
wsrep::client_context::m_replicating)
|
wsrep::client_state::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
@ -205,7 +205,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
const wsrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -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;
|
|
||||||
}
|
|
56
test/mock_client_state.cpp
Normal file
56
test/mock_client_state.cpp
Normal 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;
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
#ifndef WSREP_MOCK_CLIENT_CONTEXT_HPP
|
#ifndef WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||||
#define 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/mutex.hpp"
|
||||||
#include "wsrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
@ -13,19 +13,19 @@
|
|||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class mock_client_context : public wsrep::client_context
|
class mock_client_state : public wsrep::client_state
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mock_client_context(wsrep::server_context& server_context,
|
mock_client_state(wsrep::server_context& server_context,
|
||||||
wsrep::client_service& client_service,
|
wsrep::client_service& client_service,
|
||||||
const wsrep::client_id& id,
|
const wsrep::client_id& id,
|
||||||
enum wsrep::client_context::mode mode)
|
enum wsrep::client_state::mode mode)
|
||||||
: wsrep::client_context(mutex_, server_context, client_service, id, mode)
|
: wsrep::client_state(mutex_, server_context, client_service, id, mode)
|
||||||
// Note: Mutex is initialized only after passed
|
// Note: Mutex is initialized only after passed
|
||||||
// to client_context constructor.
|
// to client_state constructor.
|
||||||
, mutex_()
|
, mutex_()
|
||||||
{ }
|
{ }
|
||||||
~mock_client_context()
|
~mock_client_state()
|
||||||
{
|
{
|
||||||
if (transaction().active())
|
if (transaction().active())
|
||||||
{
|
{
|
||||||
@ -57,12 +57,12 @@ namespace wsrep
|
|||||||
, aborts_()
|
, 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;
|
WSREP_OVERRIDE;
|
||||||
|
|
||||||
int rollback(wsrep::client_context&) WSREP_OVERRIDE;
|
int rollback(wsrep::client_state&) WSREP_OVERRIDE;
|
||||||
|
|
||||||
bool is_autocommit() const WSREP_OVERRIDE
|
bool is_autocommit() const WSREP_OVERRIDE
|
||||||
{ return is_autocommit_; }
|
{ return is_autocommit_; }
|
||||||
@ -85,30 +85,30 @@ namespace wsrep
|
|||||||
WSREP_OVERRIDE { }
|
WSREP_OVERRIDE { }
|
||||||
|
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
replay(wsrep::client_context& client_context,
|
replay(wsrep::client_state& client_state,
|
||||||
wsrep::transaction_context& tc) WSREP_OVERRIDE
|
wsrep::transaction_context& tc) WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
enum wsrep::provider::status ret(
|
enum wsrep::provider::status ret(
|
||||||
provider_.replay(tc.ws_handle(), &client_context));
|
provider_.replay(tc.ws_handle(), &client_state));
|
||||||
++replays_;
|
++replays_;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_for_replayers(
|
void wait_for_replayers(
|
||||||
wsrep::client_context& client_context,
|
wsrep::client_state& client_state,
|
||||||
wsrep::unique_lock<wsrep::mutex>& lock)
|
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
WSREP_OVERRIDE
|
WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
if (bf_abort_during_wait_)
|
if (bf_abort_during_wait_)
|
||||||
{
|
{
|
||||||
wsrep_test::bf_abort_unordered(client_context);
|
wsrep_test::bf_abort_unordered(client_state);
|
||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepare_data_for_replication(
|
int prepare_data_for_replication(
|
||||||
wsrep::client_context& client_context,
|
wsrep::client_state& client_state,
|
||||||
const wsrep::transaction_context&) WSREP_OVERRIDE
|
const wsrep::transaction_context&) WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
if (error_during_prepare_data_)
|
if (error_during_prepare_data_)
|
||||||
@ -117,7 +117,7 @@ namespace wsrep
|
|||||||
}
|
}
|
||||||
static const char buf[1] = { 1 };
|
static const char buf[1] = { 1 };
|
||||||
wsrep::const_buffer data = wsrep::const_buffer(buf, 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
|
size_t bytes_generated() const
|
||||||
@ -126,7 +126,7 @@ namespace wsrep
|
|||||||
}
|
}
|
||||||
|
|
||||||
int prepare_fragment_for_replication(
|
int prepare_fragment_for_replication(
|
||||||
wsrep::client_context& client_context,
|
wsrep::client_state& client_state,
|
||||||
const wsrep::transaction_context&,
|
const wsrep::transaction_context&,
|
||||||
wsrep::mutable_buffer& buffer)
|
wsrep::mutable_buffer& buffer)
|
||||||
WSREP_OVERRIDE
|
WSREP_OVERRIDE
|
||||||
@ -138,12 +138,12 @@ namespace wsrep
|
|||||||
static const char buf[1] = { 1 };
|
static const char buf[1] = { 1 };
|
||||||
buffer.push_back(&buf[0], &buf[1]);
|
buffer.push_back(&buf[0], &buf[1]);
|
||||||
wsrep::const_buffer data(buffer.data(), buffer.size());
|
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 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
|
const char* sync_point) WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
if (sync_point_enabled_ == sync_point)
|
if (sync_point_enabled_ == sync_point)
|
||||||
@ -151,10 +151,10 @@ namespace wsrep
|
|||||||
switch (sync_point_action_)
|
switch (sync_point_action_)
|
||||||
{
|
{
|
||||||
case spa_bf_abort_unordered:
|
case spa_bf_abort_unordered:
|
||||||
wsrep_test::bf_abort_unordered(client_context);
|
wsrep_test::bf_abort_unordered(client_state);
|
||||||
break;
|
break;
|
||||||
case spa_bf_abort_ordered:
|
case spa_bf_abort_ordered:
|
||||||
wsrep_test::bf_abort_ordered(client_context);
|
wsrep_test::bf_abort_ordered(client_state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -154,8 +154,8 @@ namespace wsrep
|
|||||||
|
|
||||||
enum wsrep::provider::status replay(wsrep::ws_handle&, void* ctx)
|
enum wsrep::provider::status replay(wsrep::ws_handle&, void* ctx)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(
|
wsrep::client_state& cc(
|
||||||
*static_cast<wsrep::client_context*>(ctx));
|
*static_cast<wsrep::client_state*>(ctx));
|
||||||
wsrep::high_priority_context high_priority_context(cc);
|
wsrep::high_priority_context high_priority_context(cc);
|
||||||
const wsrep::transaction_context& tc(cc.transaction());
|
const wsrep::transaction_context& tc(cc.transaction());
|
||||||
wsrep::ws_meta ws_meta;
|
wsrep::ws_meta ws_meta;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define WSREP_MOCK_SERVER_CONTEXT_HPP
|
#define WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||||
|
|
||||||
#include "wsrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "mock_client_context.hpp"
|
#include "mock_client_state.hpp"
|
||||||
#include "mock_provider.hpp"
|
#include "mock_provider.hpp"
|
||||||
|
|
||||||
#include "wsrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
@ -29,24 +29,24 @@ namespace wsrep
|
|||||||
{ }
|
{ }
|
||||||
wsrep::mock_provider& provider() const
|
wsrep::mock_provider& provider() const
|
||||||
{ return provider_; }
|
{ 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_,
|
*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_,
|
*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&)
|
const wsrep::ws_meta&)
|
||||||
WSREP_OVERRIDE
|
WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
@ -60,11 +60,11 @@ namespace wsrep
|
|||||||
void on_sst_request(const std::string&,
|
void on_sst_request(const std::string&,
|
||||||
const wsrep::gtid&,
|
const wsrep::gtid&,
|
||||||
bool) WSREP_OVERRIDE { }
|
bool) WSREP_OVERRIDE { }
|
||||||
void background_rollback(wsrep::client_context& client_context)
|
void background_rollback(wsrep::client_state& client_state)
|
||||||
WSREP_OVERRIDE
|
WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
client_context.before_rollback();
|
client_state.before_rollback();
|
||||||
client_context.after_rollback();
|
client_state.after_rollback();
|
||||||
}
|
}
|
||||||
// void sst_received(const wsrep_gtid_t&, int) WSREP_OVERRIDE { }
|
// void sst_received(const wsrep_gtid_t&, int) WSREP_OVERRIDE { }
|
||||||
// void on_apply(wsrep::transaction_context&) { }
|
// void on_apply(wsrep::transaction_context&) { }
|
||||||
|
@ -15,7 +15,7 @@ namespace
|
|||||||
wsrep::server_context::rm_sync)
|
wsrep::server_context::rm_sync)
|
||||||
, cc(sc, sc.client_service(),
|
, cc(sc, sc.client_service(),
|
||||||
wsrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
wsrep::client_context::m_high_priority)
|
wsrep::client_state::m_high_priority)
|
||||||
, ws_handle(1, (void*)1)
|
, ws_handle(1, (void*)1)
|
||||||
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
, ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
||||||
wsrep::stid(wsrep::id("1"), 1, 1),
|
wsrep::stid(wsrep::id("1"), 1, 1),
|
||||||
@ -25,7 +25,7 @@ namespace
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
wsrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
wsrep::mock_client_context cc;
|
wsrep::mock_client_state cc;
|
||||||
wsrep::ws_handle ws_handle;
|
wsrep::ws_handle ws_handle;
|
||||||
wsrep::ws_meta ws_meta;
|
wsrep::ws_meta ws_meta;
|
||||||
};
|
};
|
||||||
@ -86,10 +86,10 @@ BOOST_AUTO_TEST_CASE(server_context_streaming)
|
|||||||
{
|
{
|
||||||
wsrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
wsrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
wsrep::mock_client_context cc(sc,
|
wsrep::mock_client_state cc(sc,
|
||||||
sc.client_service(),
|
sc.client_service(),
|
||||||
wsrep::client_id(1),
|
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_handle ws_handle(1, (void*)1);
|
||||||
wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
||||||
wsrep::stid(wsrep::id("1"), 1, 1),
|
wsrep::stid(wsrep::id("1"), 1, 1),
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
#include "wsrep/client_context.hpp"
|
#include "wsrep/client_state.hpp"
|
||||||
#include "mock_server_context.hpp"
|
#include "mock_server_context.hpp"
|
||||||
|
|
||||||
|
|
||||||
// Simple BF abort method to BF abort unordered transasctions
|
// 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);
|
assert(cc.transaction().ordered() == false);
|
||||||
cc.bf_abort(wsrep::seqno(1));
|
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());
|
assert(cc.transaction().ordered());
|
||||||
cc.bf_abort(wsrep::seqno(0));
|
cc.bf_abort(wsrep::seqno(0));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// Forward declarations
|
// Forward declarations
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class client_context;
|
class client_state;
|
||||||
class mock_server_context;
|
class mock_server_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,10 +19,10 @@ namespace wsrep_test
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Simple BF abort method to BF abort unordered transasctions
|
// 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
|
// 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
|
// BF abort method to abort transactions via provider
|
||||||
void bf_abort_provider(wsrep::mock_server_context& sc,
|
void bf_abort_provider(wsrep::mock_server_context& sc,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "wsrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
|
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
#include "client_context_fixture.hpp"
|
#include "client_state_fixture.hpp"
|
||||||
|
|
||||||
#include <boost/mpl/vector.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,
|
BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_1pc, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(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);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
// Verify that the commit can be succesfully executed in separate command
|
// 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_before_result();
|
||||||
cc.after_command_after_result();
|
cc.after_command_after_result();
|
||||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
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,
|
BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_context_rollback, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -117,7 +117,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
transaction_context_1pc_bf_before_before_commit, T,
|
transaction_context_1pc_bf_before_before_commit, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -159,7 +159,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -199,7 +199,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -238,7 +238,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -278,7 +278,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -344,7 +344,7 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
|
|
||||||
BOOST_REQUIRE(cc.before_commit());
|
BOOST_REQUIRE(cc.before_commit());
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
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(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
@ -360,7 +360,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -403,7 +403,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
@ -421,7 +421,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
@ -436,7 +436,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -477,7 +477,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -518,7 +518,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -559,7 +559,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -600,7 +600,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -641,7 +641,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -683,7 +683,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -725,7 +725,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::mock_server_context& sc(T::sc);
|
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);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -766,7 +766,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
transaction_context_1pc_bf_before_before_statement, T,
|
transaction_context_1pc_bf_before_before_statement, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
@ -798,7 +798,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
|||||||
transaction_context_1pc_bf_before_after_statement, T,
|
transaction_context_1pc_bf_before_after_statement, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
// Start a new transaction with ID 1
|
// 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,
|
transaction_context_1pc_bf_abort_after_after_statement, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
cc.after_statement();
|
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);
|
wsrep_test::bf_abort_unordered(cc);
|
||||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
@ -853,25 +853,25 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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.active() == false);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
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(
|
BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||||
transaction_context_1pc_bf_abort_after_after_command_before_result, T,
|
transaction_context_1pc_bf_abort_after_after_command_before_result, T,
|
||||||
replicating_fixtures, T)
|
replicating_fixtures, T)
|
||||||
{
|
{
|
||||||
wsrep::client_context& cc(T::cc);
|
wsrep::client_state& cc(T::cc);
|
||||||
const wsrep::transaction_context& tc(T::tc);
|
const wsrep::transaction_context& tc(T::tc);
|
||||||
|
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
cc.after_statement();
|
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();
|
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);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
wsrep_test::bf_abort_unordered(cc);
|
wsrep_test::bf_abort_unordered(cc);
|
||||||
// The result is being sent to client. We need to mark transaction
|
// 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
|
// After the result has been sent to the DBMS client, the after result
|
||||||
// processing should roll back the transaction and set the error.
|
// processing should roll back the transaction and set the error.
|
||||||
cc.after_command_after_result();
|
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(cc.current_error() == wsrep::e_deadlock_error);
|
||||||
BOOST_REQUIRE(tc.active() == true);
|
BOOST_REQUIRE(tc.active() == true);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
@ -902,11 +902,11 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
cc.after_statement();
|
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();
|
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();
|
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);
|
wsrep_test::bf_abort_unordered(cc);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
@ -927,11 +927,11 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
cc.after_statement();
|
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();
|
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();
|
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);
|
wsrep_test::bf_abort_unordered(cc);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
|
||||||
BOOST_REQUIRE(tc.active());
|
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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.start_transaction(1) == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
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.before_statement() == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 2);
|
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 2);
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 3);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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(tc.streaming_context_.fragments_certified() == 1);
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().rollback_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;
|
sc.provider().certify_result_ = wsrep::provider::success;
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().rollback_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;
|
sc.provider().certify_result_ = wsrep::provider::success;
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
BOOST_REQUIRE(sc.provider().fragments() == 2);
|
BOOST_REQUIRE(sc.provider().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
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.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
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(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
BOOST_REQUIRE(sc.provider().fragments() == 2);
|
BOOST_REQUIRE(sc.provider().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.start_transaction(1) == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 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(tc.streaming_context_.fragments_certified() == 1);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.start_transaction(1) == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 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(tc.streaming_context_.fragments_certified() == 0);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 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(tc.streaming_context_.fragments_certified() == 1);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||||
sc.provider().certify_result_ = wsrep::provider::error_certification_failed;
|
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(cc.current_error() == wsrep::e_deadlock_error);
|
||||||
BOOST_REQUIRE(sc.provider().fragments() == 0);
|
BOOST_REQUIRE(sc.provider().fragments() == 0);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 0);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 0);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "client_context_fixture.hpp"
|
#include "client_state_fixture.hpp"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test a succesful 2PC transaction lifecycle
|
// 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(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
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.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == 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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 2);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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.start_transaction(1) == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
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.before_statement() == 0);
|
||||||
BOOST_REQUIRE(cc.after_row() == 0);
|
BOOST_REQUIRE(cc.after_row() == 0);
|
||||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 2);
|
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.before_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(cc.after_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().fragments() == 3);
|
||||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||||
BOOST_REQUIRE(sc.provider().commit_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(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
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.state() == wsrep::transaction_context::s_committed);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
|
Reference in New Issue
Block a user