Skip to content

Commit

Permalink
Merge pull request #828 from Expensify/tyler-handle-checkpoint-waitin…
Browse files Browse the repository at this point in the history
…g-quorum

Handle waiting for the database being up-to-date for a quorum transaction but getting interrupted for a checkpoint
  • Loading branch information
coleaeason authored Jul 31, 2020
2 parents 1387e1d + 769d5db commit b506c47
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,23 @@ void SQLiteNode::replicate(SQLiteNode& node, Peer* peer, SData command, SQLite&
bool quorum = !SStartsWith(command["ID"], "ASYNC");
if (quorum) {
SINFO("Waiting on DB");
if (node._localCommitNotifier.waitFor(currentCount) != SQLiteSequentialNotifier::RESULT::COMPLETED) {
return;
while (true) {
SQLiteSequentialNotifier::RESULT result = node._localCommitNotifier.waitFor(currentCount);
if (result == SQLiteSequentialNotifier::RESULT::UNKNOWN) {
// This should be impossible.
SERROR("Got UNKNOWN result from waitFor, which shouldn't happen");
} else if (result == SQLiteSequentialNotifier::RESULT::COMPLETED) {
// Success case.
break;
} else if (result == SQLiteSequentialNotifier::RESULT::CANCELED) {
SINFO("_localCommitNotifier.waitFor canceled early, returning.");
return;
} else if (result == SQLiteSequentialNotifier::RESULT::CHECKPOINT_REQUIRED) {
SINFO("Checkpoint required while waiting for DB to come up-to-date. Just waiting again.");
continue;
} else {
SERROR("Got unhandled SQLiteSequentialNotifier::RESULT value, did someone update the enum without updating this block?");
}
}
}

Expand Down

0 comments on commit b506c47

Please sign in to comment.