Skip to content

Commit e7516de

Browse files
authored
Merge pull request #1994 from Expensify/main
Update expensify_prod branch
2 parents 2ac7f98 + 48b15df commit e7516de

File tree

6 files changed

+11
-67
lines changed

6 files changed

+11
-67
lines changed

BedrockServer.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <libstuff/libstuff.h>
1515
#include <libstuff/SRandom.h>
1616
#include <libstuff/AutoTimer.h>
17-
#include <libstuff/ResourceMonitorThread.h>
1817
#include <PageLockGuard.h>
1918
#include <sqlitecluster/SQLitePeer.h>
2019

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

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

13401339
// Start the sync thread, which will start the worker threads.
13411340
SINFO("Launching sync thread '" << _syncThreadName << "'");
1342-
_syncThread = ResourceMonitorThread(&BedrockServer::syncWrapper, this);
1341+
_syncThread = thread(&BedrockServer::syncWrapper, this);
13431342
}
13441343

13451344
BedrockServer::~BedrockServer() {
@@ -1909,7 +1908,7 @@ void BedrockServer::_control(unique_ptr<BedrockCommand>& command) {
19091908
if (__quiesceThread) {
19101909
response.methodLine = "400 Already Blocked";
19111910
} else {
1912-
__quiesceThread = new ResourceMonitorThread([&]() {
1911+
__quiesceThread = new thread([&]() {
19131912
shared_ptr<SQLitePool> dbPoolCopy = _dbPool;
19141913
if (dbPoolCopy) {
19151914
SQLiteScopedHandle dbScope(*_dbPool, _dbPool->getIndex());
@@ -2139,7 +2138,7 @@ void BedrockServer::_acceptSockets() {
21392138
bool threadStarted = false;
21402139
while (!threadStarted) {
21412140
try {
2142-
t = ResourceMonitorThread(&BedrockServer::handleSocket, this, move(socket), port == _controlPort, port == _commandPortPublic, port == _commandPortPrivate);
2141+
t = thread(&BedrockServer::handleSocket, this, move(socket), port == _controlPort, port == _commandPortPublic, port == _commandPortPrivate);
21432142
threadStarted = true;
21442143
} catch (const system_error& e) {
21452144
// We don't care about this lock here from a performance perspective, it only happens when we

libstuff/ResourceMonitorThread.cpp

-26
This file was deleted.

libstuff/ResourceMonitorThread.h

-31
This file was deleted.

plugins/DB.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ bool BedrockDBCommand::peek(SQLite& db) {
7272
return false;
7373
}
7474

75+
// We rollback here because if we are in a transaction and the querytakes long (which the queries in this command can)
76+
// it prevents sqlite from checkpointing and if we accumulate a lot of things to checkpoint, things become slow
77+
((SQLite&) db).rollback();
78+
7579
// Attempt the read-only query
7680
SQResult result;
7781
if (!db.read(query, result)) {

sqlitecluster/SQLiteClusterMessenger.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <sqlitecluster/SQLiteClusterMessenger.h>
33
#include <sqlitecluster/SQLiteNode.h>
44
#include <sqlitecluster/SQLitePeer.h>
5-
#include <libstuff/ResourceMonitorThread.h>
65

76
#include <unistd.h>
87
#include <fcntl.h>
@@ -70,7 +69,7 @@ SQLiteClusterMessenger::WaitForReadyResult SQLiteClusterMessenger::waitForReady(
7069
}
7170

7271
vector<SData> SQLiteClusterMessenger::runOnAll(const SData& cmd) {
73-
list<ResourceMonitorThread> threads;
72+
list<thread> threads;
7473
const list<STable> peerInfo = _node->getPeerInfo();
7574
vector<SData> results(peerInfo.size());
7675
atomic<size_t> index = 0;

sqlitecluster/SQLiteNode.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <libstuff/AutoScopeOnPrepare.h>
66
#include <libstuff/libstuff.h>
7-
#include <libstuff/ResourceMonitorThread.h>
87
#include <libstuff/SRandom.h>
98
#include <libstuff/SQResult.h>
109
#include <sqlitecluster/SQLiteCommand.h>
@@ -1507,7 +1506,7 @@ void SQLiteNode::_onMESSAGE(SQLitePeer* peer, const SData& message) {
15071506
} else {
15081507
_pendingSynchronizeResponses++;
15091508
static atomic<size_t> synchronizeCount(0);
1510-
ResourceMonitorThread([message, peer, currentSynchronizeCount = synchronizeCount++, this] () {
1509+
thread([message, peer, currentSynchronizeCount = synchronizeCount++, this] () {
15111510
SInitialize("synchronize" + to_string(currentSynchronizeCount));
15121511
SData response("SYNCHRONIZE_RESPONSE");
15131512
SQLiteScopedHandle dbScope(*_dbPool, _dbPool->getIndex());

0 commit comments

Comments
 (0)