1
0
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:
Teemu Ollakka
2018-07-02 10:09:48 +03:00
parent db18e91c42
commit 658a84a7d4
7 changed files with 25 additions and 21 deletions

View File

@ -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_()

View File

@ -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_;

View File

@ -15,12 +15,14 @@ namespace db
{
public:
client_state(wsrep::mutex& mutex,
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,
cond,
server_state,
client_service,
client_id,

View File

@ -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_;

View File

@ -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);

View File

@ -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;
}

View File

@ -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:
};