diff --git a/sqlitecluster/SQLiteNode.cpp b/sqlitecluster/SQLiteNode.cpp index 356333e73..e52bfa43c 100644 --- a/sqlitecluster/SQLiteNode.cpp +++ b/sqlitecluster/SQLiteNode.cpp @@ -405,12 +405,12 @@ int SQLiteNode::getPriority() const { } void SQLiteNode::setShutdownPriority() { - SINFO("Setting priority to 1, will stop leading if required."); + SINFO("Setting priority to 1."); unique_lock uniqueLock(_stateMutex); _priority = 1; if (_state == SQLiteNodeState::LEADING) { - _changeState(SQLiteNodeState::STANDINGDOWN); + SINFO("Will stop leading."); } else { SData state("STATE"); state["StateChangeCount"] = to_string(_stateChangeCount); @@ -591,6 +591,7 @@ bool SQLiteNode::update() { // If no peers, we're the leader, unless we're shutting down. if (_peerList.empty()) { SHMMM("No peers configured, jumping to LEADING"); + _priority = _originalPriority; _changeState(SQLiteNodeState::LEADING); // Run `update` again immediately. @@ -1124,7 +1125,9 @@ bool SQLiteNode::update() { // Check to see if we should stand down. We'll finish any outstanding commits before we actually do. if (_state == SQLiteNodeState::LEADING) { string standDownReason; - if (_isShuttingDown) { + if (_priority == 1) { + standDownReason = "Priority changed to 1, standing down."; + } else if (_isShuttingDown) { // Graceful shutdown. Set priority 1 and stand down so we'll re-connect to the new leader and finish // up our commands. standDownReason = "Shutting down, setting priority 1 and STANDINGDOWN.";