Skip to content

Commit

Permalink
Merge pull request #1994 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
danieldoglas authored Dec 2, 2024
2 parents 2ac7f98 + 48b15df commit e7516de
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 67 deletions.
11 changes: 5 additions & 6 deletions BedrockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <libstuff/libstuff.h>
#include <libstuff/SRandom.h>
#include <libstuff/AutoTimer.h>
#include <libstuff/ResourceMonitorThread.h>
#include <PageLockGuard.h>
#include <sqlitecluster/SQLitePeer.h>

Expand Down Expand Up @@ -118,9 +117,9 @@ void BedrockServer::sync()
// our worker threads now. We don't wait until the node is `LEADING` or `FOLLOWING`, as it's state can change while
// it's running, and our workers will have to maintain awareness of that state anyway.
SINFO("Starting " << workerThreads << " worker threads.");
list<ResourceMonitorThread> workerThreadList;
list<thread> workerThreadList;
for (int threadId = 0; threadId < workerThreads; threadId++) {
workerThreadList.emplace_back([this, threadId](){this->worker(threadId);});
workerThreadList.emplace_back(&BedrockServer::worker, this, threadId);
}

// Now we jump into our main command processing loop.
Expand Down Expand Up @@ -1339,7 +1338,7 @@ BedrockServer::BedrockServer(const SData& args_)

// Start the sync thread, which will start the worker threads.
SINFO("Launching sync thread '" << _syncThreadName << "'");
_syncThread = ResourceMonitorThread(&BedrockServer::syncWrapper, this);
_syncThread = thread(&BedrockServer::syncWrapper, this);
}

BedrockServer::~BedrockServer() {
Expand Down Expand Up @@ -1909,7 +1908,7 @@ void BedrockServer::_control(unique_ptr<BedrockCommand>& command) {
if (__quiesceThread) {
response.methodLine = "400 Already Blocked";
} else {
__quiesceThread = new ResourceMonitorThread([&]() {
__quiesceThread = new thread([&]() {
shared_ptr<SQLitePool> dbPoolCopy = _dbPool;
if (dbPoolCopy) {
SQLiteScopedHandle dbScope(*_dbPool, _dbPool->getIndex());
Expand Down Expand Up @@ -2139,7 +2138,7 @@ void BedrockServer::_acceptSockets() {
bool threadStarted = false;
while (!threadStarted) {
try {
t = ResourceMonitorThread(&BedrockServer::handleSocket, this, move(socket), port == _controlPort, port == _commandPortPublic, port == _commandPortPrivate);
t = thread(&BedrockServer::handleSocket, this, move(socket), port == _controlPort, port == _commandPortPublic, port == _commandPortPrivate);
threadStarted = true;
} catch (const system_error& e) {
// We don't care about this lock here from a performance perspective, it only happens when we
Expand Down
26 changes: 0 additions & 26 deletions libstuff/ResourceMonitorThread.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions libstuff/ResourceMonitorThread.h

This file was deleted.

4 changes: 4 additions & 0 deletions plugins/DB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ bool BedrockDBCommand::peek(SQLite& db) {
return false;
}

// We rollback here because if we are in a transaction and the querytakes long (which the queries in this command can)
// it prevents sqlite from checkpointing and if we accumulate a lot of things to checkpoint, things become slow
((SQLite&) db).rollback();

// Attempt the read-only query
SQResult result;
if (!db.read(query, result)) {
Expand Down
3 changes: 1 addition & 2 deletions sqlitecluster/SQLiteClusterMessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <sqlitecluster/SQLiteClusterMessenger.h>
#include <sqlitecluster/SQLiteNode.h>
#include <sqlitecluster/SQLitePeer.h>
#include <libstuff/ResourceMonitorThread.h>

#include <unistd.h>
#include <fcntl.h>
Expand Down Expand Up @@ -70,7 +69,7 @@ SQLiteClusterMessenger::WaitForReadyResult SQLiteClusterMessenger::waitForReady(
}

vector<SData> SQLiteClusterMessenger::runOnAll(const SData& cmd) {
list<ResourceMonitorThread> threads;
list<thread> threads;
const list<STable> peerInfo = _node->getPeerInfo();
vector<SData> results(peerInfo.size());
atomic<size_t> index = 0;
Expand Down
3 changes: 1 addition & 2 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <libstuff/AutoScopeOnPrepare.h>
#include <libstuff/libstuff.h>
#include <libstuff/ResourceMonitorThread.h>
#include <libstuff/SRandom.h>
#include <libstuff/SQResult.h>
#include <sqlitecluster/SQLiteCommand.h>
Expand Down Expand Up @@ -1507,7 +1506,7 @@ void SQLiteNode::_onMESSAGE(SQLitePeer* peer, const SData& message) {
} else {
_pendingSynchronizeResponses++;
static atomic<size_t> synchronizeCount(0);
ResourceMonitorThread([message, peer, currentSynchronizeCount = synchronizeCount++, this] () {
thread([message, peer, currentSynchronizeCount = synchronizeCount++, this] () {
SInitialize("synchronize" + to_string(currentSynchronizeCount));
SData response("SYNCHRONIZE_RESPONSE");
SQLiteScopedHandle dbScope(*_dbPool, _dbPool->getIndex());
Expand Down

0 comments on commit e7516de

Please sign in to comment.