Skip to content

Commit

Permalink
Merge pull request #2014 from Expensify/main
Browse files Browse the repository at this point in the history
  • Loading branch information
iwiznia authored Dec 10, 2024
2 parents 4b9c008 + 57c849f commit 7f5c032
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
3 changes: 2 additions & 1 deletion BedrockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ void BedrockServer::sync()
// we're leading, then the next update() loop will set us to standing down, and then we won't accept any new
// commands, and we'll shortly run through the existing queue.
if (_shutdownState.load() == COMMANDS_FINISHED) {
SINFO("All clients responded to, " << BedrockCommand::getCommandCount() << " commands remaining. Shutting down sync node.");
SINFO("All clients responded to, " << BedrockCommand::getCommandCount() << " commands remaining.");
if (_syncNode->beginShutdown()) {
SINFO("Beginning shuttdown of sync node.");
// This will cause us to skip the next `poll` iteration which avoids a 1 second wait.
_notifyDoneSync.push(true);
}
Expand Down
22 changes: 12 additions & 10 deletions libstuff/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** 65b753735b8e8fb70d2b522d527426f1eb5c.
** df4183ace93b788b798b258274bf6b651906.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
Expand Down Expand Up @@ -465,7 +465,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-12-06 17:52:38 65b753735b8e8fb70d2b522d527426f1eb5c09339fb4b15cf69cbd2e595b160f"
#define SQLITE_SOURCE_ID "2024-12-10 14:56:20 df4183ace93b788b798b258274bf6b651906c9f1cf2af4983e447cdf52904523"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down Expand Up @@ -71575,7 +71575,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
** writer lock retried until either the busy-handler returns 0 or the
** lock is successfully obtained.
*/
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){
if( eMode!=SQLITE_CHECKPOINT_PASSIVE && isWalMode2(pWal)==0 ){
rc = walBusyLock(pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, 1);
if( rc==SQLITE_OK ){
pWal->writeLock = 1;
Expand Down Expand Up @@ -93474,7 +93474,7 @@ SQLITE_PRIVATE void sqlite3CommitTimeLog(u64 *aCommit){
}
zStr = sqlite3_mprintf("%z%s%s%d%s", zStr, (zStr?", ":""),zHash,iVal,zU);
}
sqlite3_log(SQLITE_WARNING, "slow commit (v=16): (%s)", zStr);
sqlite3_log(SQLITE_WARNING, "slow commit (v=17): (%s)", zStr);
sqlite3_free(zStr);
}
}
Expand Down Expand Up @@ -93502,7 +93502,7 @@ SQLITE_PRIVATE void sqlite3PrepareTimeLog(const char *zSql, int nSql, u64 *aPrep
}
if( nByte<0 ){ nByte = sqlite3Strlen30(zSql); }
sqlite3_log(SQLITE_WARNING,
"slow prepare (v=16): (%s) [%.*s]", zStr, nByte, zSql
"slow prepare (v=17): (%s) [%.*s]", zStr, nByte, zSql
);
sqlite3_free(zStr);
}
Expand All @@ -93514,11 +93514,13 @@ SQLITE_PRIVATE void sqlite3SchemaTimeLog(u64 *aSchema, const char *zFile){
char *zStr = 0;
int ii;
for(ii=1; ii<SCHEMA_TIME_N; ii++){
zStr = sqlite3_mprintf("%z%s%d", zStr, (zStr?", ":""),
(aSchema[ii]==0 ? 0 : (int)(aSchema[ii] - i1))
);
int val = aSchema[ii];
if( val!=0 && ii!=SCHEMA_TIME_STAT4_Q1_BODY ){
val -= i1;
}
zStr = sqlite3_mprintf("%z%s%d", zStr, (zStr?", ":""), val);
}
sqlite3_log(SQLITE_WARNING, "slow schema (%s) (v=16): (%s)", zFile, zStr);
sqlite3_log(SQLITE_WARNING, "slow schema (%s) (v=17): (%s)", zFile, zStr);
sqlite3_free(zStr);
}
}
Expand Down Expand Up @@ -257917,7 +257919,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2024-12-06 17:52:38 65b753735b8e8fb70d2b522d527426f1eb5c09339fb4b15cf69cbd2e595b160f", -1, SQLITE_TRANSIENT);
sqlite3_result_text(pCtx, "fts5: 2024-12-10 14:56:20 df4183ace93b788b798b258274bf6b651906c9f1cf2af4983e447cdf52904523", -1, SQLITE_TRANSIENT);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion libstuff/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-12-06 17:52:38 65b753735b8e8fb70d2b522d527426f1eb5c09339fb4b15cf69cbd2e595b160f"
#define SQLITE_SOURCE_ID "2024-12-10 14:56:20 df4183ace93b788b798b258274bf6b651906c9f1cf2af4983e447cdf52904523"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down
9 changes: 9 additions & 0 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,15 @@ void SQLiteNode::_onMESSAGE(SQLitePeer* peer, const SData& message) {
throw e;
}
} else if (SIEquals(message.methodLine, "BEGIN_TRANSACTION") || SIEquals(message.methodLine, "COMMIT_TRANSACTION") || SIEquals(message.methodLine, "ROLLBACK_TRANSACTION")) {
if (_state != SQLiteNodeState::FOLLOWING) {
// These messages are only valid while following, but we do not throw if we receive them in other states, as
// it's not neccesarily an error. Specifically, as we switch away from FOLLOWING, there may still be a stream
// of transactions being broadcast. We do not attempt to handle these, as we keep careful count of which
// replication threads are currently running, and reset the replication state tracking when we're not following.
// Attempting to handle replication messages in some other state will break that tracking.
SINFO("Ignoring " << message.methodLine << " in state " << stateName(_state));
return;
}
if (_replicationThreadsShouldExit) {
SINFO("Discarding replication message, stopping FOLLOWING");
} else {
Expand Down
5 changes: 3 additions & 2 deletions sqlitecluster/SQLiteSequentialNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SQLiteSequentialNotifier::RESULT SQLiteSequentialNotifier::waitFor(uint64_t valu
if (_globalResult == RESULT::CANCELED || state->result == RESULT::CANCELED) {
// It's possible that we hit the timeout here after `cancel()` has set the global value, but before we received the notification.
// This isn't a problem, and we can jump back to the top of the loop and check again. If there's some problem, we'll see it there.
SINFO("Hit 1s timeout while global cancel " << (_globalResult == RESULT::CANCELED) << " or " << " specific cancel " << (state->result == RESULT::CANCELED));
SINFO("Hit 1s timeout while global cancel " << (_globalResult == RESULT::CANCELED) << " or specific cancel " << (state->result == RESULT::CANCELED));
continue;
}
}
Expand Down Expand Up @@ -114,11 +114,12 @@ void SQLiteSequentialNotifier::cancel(uint64_t cancelAfter) {
auto& valueThreadMap = *valueThreadMapPtr;
// If cancelAfter is specified, start from that value. Otherwise, we start from the beginning.
auto start = _cancelAfter ? valueThreadMap.upper_bound(_cancelAfter) : valueThreadMap.begin();
SINFO("[performance] Next value to cancel after " << cancelAfter << " is " << start->first);
if (start == valueThreadMap.end()) {
// There's nothing to remove.
SINFO("[performance] No available values to cancel after " << cancelAfter);
return;
}
SINFO("[performance] Next value to cancel after " << cancelAfter << " is " << start->first);

// Now iterate across whatever's remaining and mark it canceled.
auto current = start;
Expand Down

0 comments on commit 7f5c032

Please sign in to comment.