Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update expensify_prod branch #1781

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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