mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
Fixed BF abort in sync rollback mode.
* Pass condition variable for client_state * Notify all cond waiters when changing the transcation status to aborted * Wait for aborting transaction state aborted in before_command
This commit is contained in:
@ -12,10 +12,11 @@ db::client::client(db::server& server,
|
||||
enum wsrep::client_state::mode mode,
|
||||
const db::params& params)
|
||||
: mutex_()
|
||||
, cond_()
|
||||
, params_(params)
|
||||
, server_(server)
|
||||
, server_state_(server.server_state())
|
||||
, client_state_(mutex_, this, server_state_, client_service_, client_id, mode)
|
||||
, client_state_(mutex_, cond_, this, server_state_, client_service_, client_id, mode)
|
||||
, client_service_(client_state_)
|
||||
, se_trx_(server.storage_engine())
|
||||
, stats_()
|
||||
|
@ -52,6 +52,7 @@ namespace db
|
||||
void reset_error();
|
||||
void report_progress(size_t) const;
|
||||
wsrep::default_mutex mutex_;
|
||||
wsrep::default_condition_variable cond_;
|
||||
const db::params& params_;
|
||||
db::server& server_;
|
||||
db::server_state& server_state_;
|
||||
|
@ -15,16 +15,18 @@ namespace db
|
||||
{
|
||||
public:
|
||||
client_state(wsrep::mutex& mutex,
|
||||
db::client* client,
|
||||
db::server_state& server_state,
|
||||
wsrep::client_service& client_service,
|
||||
const wsrep::client_id& client_id,
|
||||
enum wsrep::client_state::mode mode)
|
||||
wsrep::condition_variable& cond,
|
||||
db::client* client,
|
||||
db::server_state& server_state,
|
||||
wsrep::client_service& client_service,
|
||||
const wsrep::client_id& client_id,
|
||||
enum wsrep::client_state::mode mode)
|
||||
: wsrep::client_state(mutex,
|
||||
server_state,
|
||||
client_service,
|
||||
client_id,
|
||||
mode)
|
||||
cond,
|
||||
server_state,
|
||||
client_service,
|
||||
client_id,
|
||||
mode)
|
||||
, client_(client)
|
||||
, is_autocommit_(false)
|
||||
, do_2pc_(false)
|
||||
|
@ -604,6 +604,7 @@ namespace wsrep
|
||||
* can be called from derived class constructors only.
|
||||
*/
|
||||
client_state(wsrep::mutex& mutex,
|
||||
wsrep::condition_variable& cond,
|
||||
wsrep::server_state& server_state,
|
||||
wsrep::client_service& client_service,
|
||||
const client_id& id,
|
||||
@ -611,6 +612,7 @@ namespace wsrep
|
||||
: owning_thread_id_(wsrep::this_thread::get_id())
|
||||
, current_thread_id_(owning_thread_id_)
|
||||
, mutex_(mutex)
|
||||
, cond_(cond)
|
||||
, server_state_(server_state)
|
||||
, client_service_(client_service)
|
||||
, id_(id)
|
||||
@ -645,6 +647,7 @@ namespace wsrep
|
||||
wsrep::thread::id owning_thread_id_;
|
||||
wsrep::thread::id current_thread_id_;
|
||||
wsrep::mutex& mutex_;
|
||||
wsrep::condition_variable& cond_;
|
||||
wsrep::server_state& server_state_;
|
||||
wsrep::client_service& client_service_;
|
||||
wsrep::client_id id_;
|
||||
|
@ -65,15 +65,12 @@ int wsrep::client_state::before_command()
|
||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||
debug_log_state("before_command: enter");
|
||||
assert(state_ == s_idle);
|
||||
if (server_state_.rollback_mode() == wsrep::server_state::rm_sync)
|
||||
if (transaction_.active() &&
|
||||
server_state_.rollback_mode() == wsrep::server_state::rm_sync)
|
||||
{
|
||||
/**
|
||||
* @todo Wait until the possible synchronous rollback
|
||||
* has been finished.
|
||||
*/
|
||||
while (transaction_.state() == wsrep::transaction::s_aborting)
|
||||
{
|
||||
// cond_.wait(lock);
|
||||
cond_.wait(lock);
|
||||
}
|
||||
}
|
||||
state(lock, s_exec);
|
||||
|
@ -452,6 +452,7 @@ int wsrep::transaction::after_rollback()
|
||||
if (state() == s_aborting)
|
||||
{
|
||||
state(lock, s_aborted);
|
||||
client_state_.cond_.notify_all();
|
||||
}
|
||||
|
||||
// Releasing the transaction from provider is postponed into
|
||||
@ -820,9 +821,8 @@ int wsrep::transaction::certify_commit(
|
||||
|
||||
if (client_service_.prepare_data_for_replication())
|
||||
{
|
||||
// Note: Error must be set by prepare_data_for_replication()
|
||||
lock.lock();
|
||||
client_state_.override_error(wsrep::e_error_during_commit);
|
||||
client_state_.override_error(wsrep::e_size_exceeded_error);
|
||||
state(lock, s_must_abort);
|
||||
return 1;
|
||||
}
|
||||
|
@ -20,10 +20,9 @@ namespace wsrep
|
||||
wsrep::client_service& client_service,
|
||||
const wsrep::client_id& id,
|
||||
enum wsrep::client_state::mode mode)
|
||||
: wsrep::client_state(mutex_, server_state, client_service, id, mode)
|
||||
// Note: Mutex is initialized only after passed
|
||||
// to client_state constructor.
|
||||
: wsrep::client_state(mutex_, cond_, server_state, client_service, id, mode)
|
||||
, mutex_()
|
||||
, cond_()
|
||||
{ }
|
||||
~mock_client_state()
|
||||
{
|
||||
@ -34,6 +33,7 @@ namespace wsrep
|
||||
}
|
||||
private:
|
||||
wsrep::default_mutex mutex_;
|
||||
wsrep::default_condition_variable cond_;
|
||||
public:
|
||||
private:
|
||||
};
|
||||
|
Reference in New Issue
Block a user