1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-31 18:24:25 +03:00

Eliminated duplicate fragment removal code

Extracted duplicate fragment removal code in after_commit()
and after_rollback() into separate method.
This commit is contained in:
Teemu Ollakka
2023-03-02 08:39:37 +02:00
parent 241898af7e
commit 9a35083730
2 changed files with 24 additions and 27 deletions

View File

@ -249,6 +249,8 @@ namespace wsrep
int certify_commit(wsrep::unique_lock<wsrep::mutex>&);
int append_sr_keys_for_commit();
int release_commit_order(wsrep::unique_lock<wsrep::mutex>&);
void remove_fragments_in_storage_service_scope(
wsrep::unique_lock<wsrep::mutex>&);
void streaming_rollback(wsrep::unique_lock<wsrep::mutex>&);
int replay(wsrep::unique_lock<wsrep::mutex>&);
void xa_replay_common(wsrep::unique_lock<wsrep::mutex>&);

View File

@ -614,18 +614,7 @@ int wsrep::transaction::after_commit()
{
// XA fragment removal happens here,
// see comment in before_prepare
lock.unlock();
scoped_storage_service<storage_service_deleter>
sr_scope(
client_service_,
server_service_.storage_service(client_service_),
storage_service_deleter(server_service_));
wsrep::storage_service& storage_service(
sr_scope.storage_service());
storage_service.adopt_transaction(*this);
storage_service.remove_fragments();
storage_service.commit(wsrep::ws_handle(), wsrep::ws_meta());
lock.lock();
remove_fragments_in_storage_service_scope(lock);
}
if (client_state_.mode() == wsrep::client_state::m_local)
@ -757,21 +746,7 @@ int wsrep::transaction::after_rollback()
// MDL locks. It is not clear how to enforce that though.
if (is_streaming() && bf_aborted_in_total_order_)
{
lock.unlock();
// Storage service scope
{
scoped_storage_service<storage_service_deleter>
sr_scope(
client_service_,
server_service_.storage_service(client_service_),
storage_service_deleter(server_service_));
wsrep::storage_service& storage_service(
sr_scope.storage_service());
storage_service.adopt_transaction(*this);
storage_service.remove_fragments();
storage_service.commit(wsrep::ws_handle(), wsrep::ws_meta());
}
lock.lock();
remove_fragments_in_storage_service_scope(lock);
streaming_context_.cleanup();
}
@ -811,6 +786,26 @@ int wsrep::transaction::release_commit_order(
return ret;
}
void wsrep::transaction::remove_fragments_in_storage_service_scope(
wsrep::unique_lock<wsrep::mutex>& lock)
{
assert(lock.owns_lock());
lock.unlock();
{
scoped_storage_service<storage_service_deleter>
sr_scope(
client_service_,
server_service_.storage_service(client_service_),
storage_service_deleter(server_service_));
wsrep::storage_service& storage_service(
sr_scope.storage_service());
storage_service.adopt_transaction(*this);
storage_service.remove_fragments();
storage_service.commit(wsrep::ws_handle(), wsrep::ws_meta());
}
lock.lock();
}
int wsrep::transaction::after_statement()
{
int ret(0);