Skip to content

Commit

Permalink
Eliminated duplicate fragment removal code
Browse files Browse the repository at this point in the history
Extracted duplicate fragment removal code in after_commit()
and after_rollback() into separate method.
  • Loading branch information
temeo committed Mar 2, 2023
1 parent 241898a commit 9a35083
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
2 changes: 2 additions & 0 deletions include/wsrep/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>&);
Expand Down
49 changes: 22 additions & 27 deletions src/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9a35083

Please sign in to comment.