mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-21 12:22:06 +03:00
codership/wsrep-lib#100 Support for assign_read_view() wsrep API call
Marshall the call from the `client_state` interface down to provider.
This commit is contained in:
@ -270,6 +270,25 @@ namespace wsrep
|
|||||||
return transaction_.start_transaction(id);
|
return transaction_.start_transaction(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establish read view ID of the transaction.
|
||||||
|
*
|
||||||
|
* This method should be preferably called immediately before any
|
||||||
|
* first read or write operation in the transaction is performed,
|
||||||
|
* Then it can be called with default NULL parameter and will use
|
||||||
|
* the current last committed GTID.
|
||||||
|
* Alternatively it can be called at any time before commit with an
|
||||||
|
* explicit GTID that corresponds to transaction read view.
|
||||||
|
*
|
||||||
|
* @param gtid optional explicit GTID of the transaction read view.
|
||||||
|
*/
|
||||||
|
int assign_read_view(const wsrep::gtid* const gtid = NULL)
|
||||||
|
{
|
||||||
|
assert(mode_ == m_local);
|
||||||
|
assert(state_ == s_exec);
|
||||||
|
return transaction_.assign_read_view(gtid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a key into transaction write set.
|
* Append a key into transaction write set.
|
||||||
*/
|
*/
|
||||||
|
@ -274,6 +274,8 @@ namespace wsrep
|
|||||||
// Write set replication
|
// Write set replication
|
||||||
// TODO: Rename to assing_read_view()
|
// TODO: Rename to assing_read_view()
|
||||||
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
||||||
|
virtual enum status assign_read_view(
|
||||||
|
wsrep::ws_handle&, const wsrep::gtid*) = 0;
|
||||||
virtual int append_key(wsrep::ws_handle&, const wsrep::key&) = 0;
|
virtual int append_key(wsrep::ws_handle&, const wsrep::key&) = 0;
|
||||||
virtual enum status append_data(
|
virtual enum status append_data(
|
||||||
wsrep::ws_handle&, const wsrep::const_buffer&) = 0;
|
wsrep::ws_handle&, const wsrep::const_buffer&) = 0;
|
||||||
|
@ -138,6 +138,8 @@ namespace wsrep
|
|||||||
const wsrep::ws_meta& ws_meta,
|
const wsrep::ws_meta& ws_meta,
|
||||||
bool is_commit);
|
bool is_commit);
|
||||||
|
|
||||||
|
int assign_read_view(const wsrep::gtid* gtid);
|
||||||
|
|
||||||
int append_key(const wsrep::key&);
|
int append_key(const wsrep::key&);
|
||||||
|
|
||||||
int append_data(const wsrep::const_buffer&);
|
int append_data(const wsrep::const_buffer&);
|
||||||
|
@ -75,7 +75,7 @@ std::string wsrep::provider::capability::str(int caps)
|
|||||||
WSREP_PRINT_CAPABILITY(annotation, "ANNOTATION");
|
WSREP_PRINT_CAPABILITY(annotation, "ANNOTATION");
|
||||||
WSREP_PRINT_CAPABILITY(preordered, "PREORDERED");
|
WSREP_PRINT_CAPABILITY(preordered, "PREORDERED");
|
||||||
WSREP_PRINT_CAPABILITY(streaming, "STREAMING");
|
WSREP_PRINT_CAPABILITY(streaming, "STREAMING");
|
||||||
WSREP_PRINT_CAPABILITY(snapshot, "SNAPSHOT");
|
WSREP_PRINT_CAPABILITY(snapshot, "READ_VIEW");
|
||||||
WSREP_PRINT_CAPABILITY(nbo, "NBO");
|
WSREP_PRINT_CAPABILITY(nbo, "NBO");
|
||||||
|
|
||||||
#undef WSREP_PRINT_CAPABILITY
|
#undef WSREP_PRINT_CAPABILITY
|
||||||
@ -107,7 +107,7 @@ std::string wsrep::flags_to_string(int flags)
|
|||||||
if (flags & provider::flag::prepare)
|
if (flags & provider::flag::prepare)
|
||||||
oss << "prepare | ";
|
oss << "prepare | ";
|
||||||
if (flags & provider::flag::snapshot)
|
if (flags & provider::flag::snapshot)
|
||||||
oss << "snapshot | ";
|
oss << "read_view | ";
|
||||||
if (flags & provider::flag::implicit_deps)
|
if (flags & provider::flag::implicit_deps)
|
||||||
oss << "implicit_deps | ";
|
oss << "implicit_deps | ";
|
||||||
|
|
||||||
|
@ -208,6 +208,19 @@ int wsrep::transaction::prepare_for_ordering(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsrep::transaction::assign_read_view(const wsrep::gtid* const gtid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return provider().assign_read_view(ws_handle_, gtid);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
wsrep::log_error() << "Failed to assign read view";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int wsrep::transaction::append_key(const wsrep::key& key)
|
int wsrep::transaction::append_key(const wsrep::key& key)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -690,6 +690,25 @@ wsrep::wsrep_provider_v26::run_applier(
|
|||||||
return map_return_value(wsrep_->recv(wsrep_, applier_ctx));
|
return map_return_value(wsrep_->recv(wsrep_, applier_ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum wsrep::provider::status
|
||||||
|
wsrep::wsrep_provider_v26::assign_read_view(wsrep::ws_handle& ws_handle,
|
||||||
|
const wsrep::gtid* gtid)
|
||||||
|
{
|
||||||
|
const wsrep_gtid_t* gtid_ptr(NULL);
|
||||||
|
wsrep_gtid_t tmp;
|
||||||
|
|
||||||
|
if (gtid)
|
||||||
|
{
|
||||||
|
::memcpy(&tmp.uuid, gtid->id().data(), sizeof(tmp.uuid));
|
||||||
|
tmp.seqno = gtid->seqno().get();
|
||||||
|
gtid_ptr = &tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutable_ws_handle mwsh(ws_handle);
|
||||||
|
return map_return_value(wsrep_->assign_read_view(wsrep_, mwsh.native(),
|
||||||
|
gtid_ptr));
|
||||||
|
}
|
||||||
|
|
||||||
int wsrep::wsrep_provider_v26::append_key(wsrep::ws_handle& ws_handle,
|
int wsrep::wsrep_provider_v26::append_key(wsrep::ws_handle& ws_handle,
|
||||||
const wsrep::key& key)
|
const wsrep::key& key)
|
||||||
{
|
{
|
||||||
@ -714,7 +733,7 @@ int wsrep::wsrep_provider_v26::append_key(wsrep::ws_handle& ws_handle,
|
|||||||
|
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
wsrep::wsrep_provider_v26::append_data(wsrep::ws_handle& ws_handle,
|
wsrep::wsrep_provider_v26::append_data(wsrep::ws_handle& ws_handle,
|
||||||
const wsrep::const_buffer& data)
|
const wsrep::const_buffer& data)
|
||||||
{
|
{
|
||||||
const wsrep_buf_t wsrep_buf = {data.data(), data.size()};
|
const wsrep_buf_t wsrep_buf = {data.data(), data.size()};
|
||||||
mutable_ws_handle mwsh(ws_handle);
|
mutable_ws_handle mwsh(ws_handle);
|
||||||
|
@ -46,6 +46,8 @@ namespace wsrep
|
|||||||
|
|
||||||
enum wsrep::provider::status run_applier(wsrep::high_priority_service*);
|
enum wsrep::provider::status run_applier(wsrep::high_priority_service*);
|
||||||
int start_transaction(wsrep::ws_handle&) { return 0; }
|
int start_transaction(wsrep::ws_handle&) { return 0; }
|
||||||
|
enum wsrep::provider::status
|
||||||
|
assign_read_view(wsrep::ws_handle&, const wsrep::gtid*);
|
||||||
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
append_data(wsrep::ws_handle&, const wsrep::const_buffer&);
|
append_data(wsrep::ws_handle&, const wsrep::const_buffer&);
|
||||||
|
@ -143,6 +143,10 @@ namespace wsrep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum wsrep::provider::status
|
||||||
|
assign_read_view(wsrep::ws_handle&, const wsrep::gtid*)
|
||||||
|
WSREP_OVERRIDE
|
||||||
|
{ return wsrep::provider::success; }
|
||||||
int append_key(wsrep::ws_handle&, const wsrep::key&)
|
int append_key(wsrep::ws_handle&, const wsrep::key&)
|
||||||
WSREP_OVERRIDE
|
WSREP_OVERRIDE
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
@ -68,6 +68,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_1pc, T,
|
|||||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
|
||||||
|
|
||||||
|
// Establish default read view
|
||||||
|
BOOST_REQUIRE(0 == cc.assign_read_view(NULL));
|
||||||
|
|
||||||
// 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() == 0);
|
BOOST_REQUIRE(cc.after_statement() == 0);
|
||||||
cc.after_command_before_result();
|
cc.after_command_before_result();
|
||||||
|
Reference in New Issue
Block a user