diff --git a/BedrockServer.cpp b/BedrockServer.cpp index 0f436a71b..14397b327 100644 --- a/BedrockServer.cpp +++ b/BedrockServer.cpp @@ -725,7 +725,6 @@ void BedrockServer::runCommand(unique_ptr&& _command, bool isBlo // 2. Any commands if the current version of the code is not the same one as leader is executing. if (getState() == SQLiteNodeState::FOLLOWING && !command->complete && (command->escalateImmediately || _version != _leaderVersion.load())) { auto _clusterMessengerCopy = _clusterMessenger; - string escalatedTo = ""; if (command->escalateImmediately && _clusterMessengerCopy && _clusterMessengerCopy->runOnPeer(*command, true)) { // command->complete is now true for this command. It will get handled a few lines below. SINFO("Immediately escalated " << command->request.methodLine << " to leader."); @@ -738,6 +737,18 @@ void BedrockServer::runCommand(unique_ptr&& _command, bool isBlo } } + // If we happen to be synchronizing but the command port is open, which is an uncommon but possible scenario (i.e., we were momentarily disconnected from leader and need to catch back + // up), we will forward commands to any other follower similar to if we were running as a different version from leader. + if (getState() == SQLiteNodeState::SYNCHRONIZING) { + auto _clusterMessengerCopy = _clusterMessenger; + bool result = _clusterMessengerCopy->runOnPeer(*command, false); + if (result) { + SINFO("Synchronizing while accepting commands, so forwarded " << command->request.methodLine << " to peer successfully"); + } else { + SWARN("Synchronizing while accepting commands, so forwarded " << command->request.methodLine << " to peer, but failed."); + } + } + // If this command is already complete, then we should be a follower, and the sync node got a response back // from a command that had been escalated to leader, and queued it for a worker to respond to. We'll send // that response now.