From 2da6e4894e1df5d1db51db2bbc49255e02251b9d Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 8 Oct 2020 11:10:43 +0200 Subject: [PATCH] Unnecessary adopt/start transaction in rollback_fragment() This patch changes the handling of a rollback fragment so that the high_priority_service adopts and starts a new transaction only if fragment removal has to be performed. When no fragment removal happens, starting a new transaction is unnecessary: a dummy write set is logged instead and the transaction is not cleaned up properly in DBMS side. --- src/server_state.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/server_state.cpp b/src/server_state.cpp index 65ac80e..7b9b7d3 100644 --- a/src/server_state.cpp +++ b/src/server_state.cpp @@ -216,12 +216,14 @@ static int rollback_fragment(wsrep::server_state& server_state, const wsrep::ws_meta& ws_meta) { int ret(0); - // Adopts transaction state and starts a transaction for - // high priority service - int adopt_error; - bool remove_fragments(false); - if ((adopt_error = high_priority_service.adopt_transaction( - streaming_applier->transaction()))) + int adopt_error(0); + bool const remove_fragments(streaming_applier->transaction(). + streaming_context().fragments().size() > 0); + // If fragment removal is needed, adopt transaction state + // and start a transaction for it. + if (remove_fragments && + (adopt_error = high_priority_service.adopt_transaction( + streaming_applier->transaction()))) { log_adopt_error(streaming_applier->transaction()); } @@ -234,8 +236,6 @@ static int rollback_fragment(wsrep::server_state& server_state, high_priority_service, *streaming_applier); // Streaming applier rolls back out of order. Fragment // removal grabs commit order below. - remove_fragments = streaming_applier->transaction(). - streaming_context().fragments().size() > 0; ret = streaming_applier->rollback(wsrep::ws_handle(), wsrep::ws_meta()); ret = ret || (streaming_applier->after_apply(), 0); }