Skip to content

Commit

Permalink
Merge pull request #1697 from Expensify/aldo_fix-peek-time
Browse files Browse the repository at this point in the history
Move AutoTimer after transaction
  • Loading branch information
tylerkaraszewski authored Apr 17, 2024
2 parents e1ae0f2 + e2b984b commit 28e6573
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion BedrockCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void BedrockCore::prePeekCommand(unique_ptr<BedrockCommand>& command) {
}

BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr<BedrockCommand>& command, bool exclusive) {
AutoTimer timer(command, exclusive ? BedrockCommand::BLOCKING_PEEK : BedrockCommand::PEEK);
BedrockServer::ScopedStateSnapshot snapshot(_server);
command->lastPeekedOrProcessedInState = _server.getState();

Expand All @@ -146,6 +145,9 @@ BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr<BedrockCommand>& command
STHROW("501 Failed to begin " + (exclusive ? "exclusive"s : "shared"s) + " transaction");
}

// We start the timer here to avoid including the time spent acquiring the lock _sharedData.commitLock
AutoTimer timer(command, exclusive ? BedrockCommand::BLOCKING_PEEK : BedrockCommand::PEEK);

// Make sure no writes happen while in peek command
_db.setQueryOnly(true);

Expand Down

0 comments on commit 28e6573

Please sign in to comment.