Skip to content

Commit

Permalink
Merge pull request #1781 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
tylerkaraszewski authored Jun 17, 2024
2 parents e581b7e + 92aaa14 commit 6624352
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion BedrockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ void BedrockServer::runCommand(unique_ptr<BedrockCommand>&& _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.");
Expand All @@ -738,6 +737,18 @@ void BedrockServer::runCommand(unique_ptr<BedrockCommand>&& _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.
Expand Down

0 comments on commit 6624352

Please sign in to comment.