From 58cea105774be8942860f2d3570119c32994a420 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 5 Sep 2019 16:34:13 +0300 Subject: [PATCH] Release TOI critical section in poll_enter_toi() in case of error. --- src/client_state.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/client_state.cpp b/src/client_state.cpp index 0a19567..e21eaac 100644 --- a/src/client_state.cpp +++ b/src/client_state.cpp @@ -344,6 +344,20 @@ wsrep::client_state::poll_enter_toi( { lock.unlock(); status = provider().enter_toi(id_, keys, buffer, toi_meta_, flags); + if (status != wsrep::provider::success && + not toi_meta_.gtid().is_undefined()) + { + // Successfully entered TOI, but the provider reported failure. + // This may happen for example if certification fails. + // Leave TOI before proceeding. + if (provider().leave_toi(id_, wsrep::mutable_buffer())) + { + wsrep::log_warning() + << "Failed to leave TOI after failure in " + << "poll_enter_toi()"; + } + toi_meta_ = wsrep::ws_meta(); + } if (status == wsrep::provider::error_certification_failed) { ::usleep(100000);