Skip to content

Commit

Permalink
Merge pull request #2043 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
techievivek authored Jan 1, 2025
2 parents 0f1268d + 6367890 commit 6f437d5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,12 @@ void SQLiteNode::_updateSyncPeer()
continue;
}

// We want to sync, if possible, from a peer that is not the leader. So at this point, skip choosing it
// as the newSyncPeer.
if (peer == _leadPeer) {
continue;
}

// Any peer that makes it to here is a usable peer, so it's by default better than nothing.
if (!newSyncPeer) {
newSyncPeer = peer;
Expand All @@ -2234,6 +2240,12 @@ void SQLiteNode::_updateSyncPeer()
}
}

// If we reached this point, it means that there are no other available peers to sync from, but leader
// was a valid choice. In this case, let's use it as the newSyncPeer.
if (!newSyncPeer && _leadPeer) {
newSyncPeer = _leadPeer;
}

// Log that we've changed peers.
if (_syncPeer != newSyncPeer) {
string from, to;
Expand Down

0 comments on commit 6f437d5

Please sign in to comment.