From 244eabe8cfcc86ca49981b0d8d081b740a967bda Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 25 May 2022 07:39:43 +0300 Subject: [PATCH] Handle disconnecting state in on_sync() When disconnecting from the group, the sync event from the provider must not change the state back to synced. --- src/server_state.cpp | 4 +++- test/server_context_test.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/server_state.cpp b/src/server_state.cpp index 719a02c..40e2b79 100644 --- a/src/server_state.cpp +++ b/src/server_state.cpp @@ -1067,6 +1067,8 @@ void wsrep::server_state::on_sync() { switch (state_) { + case s_disconnecting: + break; case s_synced: break; case s_connected: // Seed node path: provider becomes @@ -1093,7 +1095,7 @@ void wsrep::server_state::on_sync() // Calls to on_sync() in synced state are possible if // server desyncs itself from the group. Provider does not // inform about this through callbacks. - if (state_ != s_synced) + if (state_ != s_synced && state_ != s_disconnecting) { state(lock, s_synced); } diff --git a/test/server_context_test.cpp b/test/server_context_test.cpp index 6055f76..6202083 100644 --- a/test/server_context_test.cpp +++ b/test/server_context_test.cpp @@ -934,3 +934,14 @@ BOOST_FIXTURE_TEST_CASE(server_state_xa_not_orphaned, BOOST_REQUIRE(not ss.find_streaming_applier( meta_commit_s3.server_id(), meta_commit_s3.transaction_id())); } + +BOOST_FIXTURE_TEST_CASE(server_state_sync_in_disconnecting, + sst_first_server_fixture) +{ + bootstrap(); + ss.disconnect(); + BOOST_REQUIRE(ss.state() == wsrep::server_state::s_disconnecting); + // Synced event from the provider must not change the state. + ss.on_sync(); + BOOST_REQUIRE(ss.state() == wsrep::server_state::s_disconnecting); +}