Skip to content

Commit

Permalink
fix: reduce delay when stop replica #3020
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed May 8, 2024
1 parent 25e6930 commit 343b99d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server/replica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ void Replica::Stop() {
state_mask_.store(0); // Specifically ~R_ENABLED.
});

CloseSocket();
for (auto& flow : shard_flows_) {
flow->Cancel();
}

// Make sure the replica fully stopped and did all cleanup,
// so we can freely release resources (connections).
sync_fb_.JoinIfNeeded();
Expand Down Expand Up @@ -173,7 +178,7 @@ void Replica::MainReplicationFb() {
SetShardStates(true);

error_code ec;
while (state_mask_.load() & R_ENABLED) {
while (!cntx_.IsCancelled() && state_mask_.load() & R_ENABLED) {
// Discard all previous errors and set default error handler.
cntx_.Reset([this](const GenericError& ge) { this->DefaultErrorHandler(ge); });
// 1. Connect socket.
Expand Down

0 comments on commit 343b99d

Please sign in to comment.