Skip to content

Commit

Permalink
Only stop replicate thread if it was started
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerkaraszewski committed Jan 14, 2025
1 parent 89e2a3b commit 635ba5c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,12 +1817,14 @@ void SQLiteNode::_changeState(SQLiteNodeState newState, uint64_t commitIDToCance

// If we were following, and now we're not, we give up an any replications.
if (_state == SQLiteNodeState::FOLLOWING) {
_replicateThreadShouldExit = true;
_replicateCV.notify_one();
_replicateThread->join();
delete _replicateThread;
_replicateThread = nullptr;
_replicateThreadShouldExit = false;
if (_replicateThread) {
_replicateThreadShouldExit = true;
_replicateCV.notify_one();
_replicateThread->join();
delete _replicateThread;
_replicateThread = nullptr;
_replicateThreadShouldExit = false;
}

// We have no leader anymore.
_leadPeer = nullptr;
Expand Down

0 comments on commit 635ba5c

Please sign in to comment.