mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-31 18:24:25 +03:00
Unit tests for SR with two statements, SR rollback.
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include "wsrep/view.hpp"
|
||||
#include "wsrep/logger.hpp"
|
||||
#include "wsrep/compiler.hpp"
|
||||
#include "wsrep/id.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
@ -178,6 +179,21 @@ bool wsrep::server_context::statement_allowed_for_streaming(
|
||||
return false;
|
||||
}
|
||||
|
||||
void wsrep::server_context::insert_streaming_applier(
|
||||
const wsrep::id& server_id,
|
||||
const wsrep::transaction_id& transaction_id,
|
||||
wsrep::client_context* client_context)
|
||||
{
|
||||
if (streaming_appliers_.insert(
|
||||
std::make_pair(std::make_pair(server_id, transaction_id),
|
||||
client_context)).second == false)
|
||||
{
|
||||
wsrep::log_error() << "Could not insert streaming applier";
|
||||
delete client_context;
|
||||
throw wsrep::fatal_error();
|
||||
}
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
void wsrep::server_context::state(
|
||||
|
@ -367,8 +367,7 @@ int wsrep::transaction_context::before_rollback()
|
||||
// Voluntary rollback
|
||||
if (is_streaming())
|
||||
{
|
||||
// Replicate rollback fragment
|
||||
provider_.rollback(id_.get());
|
||||
streaming_rollback();
|
||||
}
|
||||
state(lock, s_aborting);
|
||||
break;
|
||||
@ -652,11 +651,6 @@ int wsrep::transaction_context::certify_fragment(
|
||||
|
||||
lock.unlock();
|
||||
|
||||
if (streaming_context_.fragments_certified())
|
||||
{
|
||||
flags_ |= wsrep::provider::flag::start_transaction;
|
||||
}
|
||||
|
||||
wsrep::mutable_buffer data;
|
||||
if (client_context_.prepare_fragment_for_replication(*this, data))
|
||||
{
|
||||
@ -869,6 +863,18 @@ int wsrep::transaction_context::certify_commit(
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::streaming_rollback()
|
||||
{
|
||||
assert(streaming_context_.rolled_back() == false);
|
||||
wsrep::client_context& applier_context(
|
||||
client_context_.server_context().streaming_applier_client_context(
|
||||
client_context_.server_context().id(), id()));
|
||||
applier_context.adopt_transaction(*this);
|
||||
streaming_context_.cleanup();
|
||||
// Replicate rollback fragment
|
||||
provider_.rollback(id_.get());
|
||||
}
|
||||
|
||||
void wsrep::transaction_context::clear_fragments()
|
||||
{
|
||||
streaming_context_.cleanup();
|
||||
@ -876,13 +882,10 @@ void wsrep::transaction_context::clear_fragments()
|
||||
|
||||
void wsrep::transaction_context::cleanup()
|
||||
{
|
||||
assert(is_streaming() == false);
|
||||
debug_log_state("cleanup_enter");
|
||||
id_ = wsrep::transaction_id::invalid();
|
||||
ws_handle_ = wsrep::ws_handle();
|
||||
if (is_streaming())
|
||||
{
|
||||
state_ = s_executing;
|
||||
}
|
||||
// Keep the state history for troubleshooting. Reset at start_transaction().
|
||||
// state_hist_.clear();
|
||||
ws_meta_ = wsrep::ws_meta();
|
||||
|
Reference in New Issue
Block a user