From 838408ff0a5f16deeeb8ca1f856ea6de30ccb004 Mon Sep 17 00:00:00 2001 From: lzydmxy <13126752315@163.com> Date: Thu, 31 Oct 2024 16:09:25 +0800 Subject: [PATCH] Force_connected for retry resume connection establisher --- src/Client/ConnectionEstablisher.cpp | 3 ++- src/Client/ConnectionEstablisher.h | 3 +++ src/Client/HedgedConnectionsFactory.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Client/ConnectionEstablisher.cpp b/src/Client/ConnectionEstablisher.cpp index 178e26b124c..d1960e51e03 100644 --- a/src/Client/ConnectionEstablisher.cpp +++ b/src/Client/ConnectionEstablisher.cpp @@ -151,7 +151,8 @@ void ConnectionEstablisherAsync::Task::run(AsyncCallback async_callback, Suspend { connection_establisher_async.reset(); connection_establisher_async.connection_establisher.setAsyncCallback(async_callback); - connection_establisher_async.connection_establisher.run(connection_establisher_async.result, connection_establisher_async.fail_message); + connection_establisher_async.connection_establisher.run(connection_establisher_async.result, + connection_establisher_async.fail_message, connection_establisher_async.force_connected); connection_establisher_async.is_finished = true; } diff --git a/src/Client/ConnectionEstablisher.h b/src/Client/ConnectionEstablisher.h index ff071e59aea..e7833237600 100644 --- a/src/Client/ConnectionEstablisher.h +++ b/src/Client/ConnectionEstablisher.h @@ -76,6 +76,8 @@ public: const std::string & getFailMessage() const { return fail_message; } + void resumeConnectionWithForceOption(bool force_connected_) {force_connected = force_connected_; resume();} + private: bool checkBeforeTaskResume() override; @@ -125,6 +127,7 @@ private: bool is_finished = false; bool restarted = false; + bool force_connected = false; }; #endif diff --git a/src/Client/HedgedConnectionsFactory.cpp b/src/Client/HedgedConnectionsFactory.cpp index df63a124539..0900f1c0293 100644 --- a/src/Client/HedgedConnectionsFactory.cpp +++ b/src/Client/HedgedConnectionsFactory.cpp @@ -281,7 +281,7 @@ int HedgedConnectionsFactory::getReadyFileDescriptor(bool blocking, AsyncCallbac HedgedConnectionsFactory::State HedgedConnectionsFactory::resumeConnectionEstablisher(int index, Connection *& connection_out) { - replicas[index].connection_establisher->resume(); + replicas[index].connection_establisher->resumeConnectionWithForceOption(/*force_connected_*/ shuffled_pools[index].error_count != 0); if (replicas[index].connection_establisher->isCancelled()) return State::CANNOT_CHOOSE;