Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/workerd/io/actor-sqlite.c++
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ kj::Maybe<kj::Promise<void>> ActorSqlite::ExplicitTxn::commit() {
// makes since given the explicit commit call.
auto commitPromise = actorSqlite.outputGate
.lockWhile(kj::evalNow([this, &precommitAlarmState]() {
return actorSqlite.commitImpl(kj::mv(KJ_ASSERT_NONNULL(precommitAlarmState)));
return actorSqlite.commitImpl(
kj::mv(KJ_ASSERT_NONNULL(precommitAlarmState)), actorSqlite.currentCommitSpan.addRef());
}),
actorSqlite.currentCommitSpan.addRef())
.fork();
Expand Down Expand Up @@ -288,10 +289,7 @@ void ActorSqlite::startImplicitTxn() {
{ auto drop = kj::mv(txn); }

// Move the commit span out immediately so new writes can capture a fresh span.
// Attach it to the promise to keep it alive for the commit duration.
auto commitSpan = kj::mv(currentCommitSpan);

return commitImpl(kj::mv(precommitAlarmState)).attach(kj::mv(commitSpan));
return commitImpl(kj::mv(precommitAlarmState), kj::mv(currentCommitSpan));
})
// Unconditionally break the output gate if commit threw an error, no matter whether the
// commit was confirmed or unconfirmed.
Expand Down Expand Up @@ -365,9 +363,9 @@ ActorSqlite::PrecommitAlarmState ActorSqlite::startPrecommitAlarmScheduling() {
return kj::mv(state);
}

kj::Promise<void> ActorSqlite::commitImpl(ActorSqlite::PrecommitAlarmState precommitAlarmState) {
// TODO(perf): Add a SpanParent parameter and create a child span here to trace the actual
// commit duration. This will help identify what's taking time during commits.
kj::Promise<void> ActorSqlite::commitImpl(
ActorSqlite::PrecommitAlarmState precommitAlarmState, SpanParent parentSpan) {
auto commitSpan = parentSpan.newChild("actor_sqlite_commit"_kjc);

// We assume that exceptions thrown during commit will propagate to the caller, such that they
// will ensure cancelDeferredAlarmDeletion() is called, if necessary.
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/io/actor-sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class ActorSqlite final: public ActorCacheInterface, private kj::TaskSet::ErrorH
// Performs the rest of the asynchronous commit, to be waited on after committing the local
// sqlite db. Should be called in the same turn of the event loop as
// startPrecommitAlarmScheduling() and passed the state that it returned.
kj::Promise<void> commitImpl(PrecommitAlarmState precommitAlarmState);
kj::Promise<void> commitImpl(PrecommitAlarmState precommitAlarmState, SpanParent parentSpan);

void taskFailed(kj::Exception&& exception) override;

Expand Down
Loading