Skip to content

Commit 02f2c17

Browse files
add duration logging to flushImpl and to waiting for prev flushes
1 parent 7bb684f commit 02f2c17

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/workerd/io/actor-cache.c++

+16-4
Original file line numberDiff line numberDiff line change
@@ -2155,10 +2155,17 @@ void ActorCache::ensureFlushScheduled(const WriteOptions& options) {
21552155

21562156
if (!flushScheduled) {
21572157
flushScheduled = true;
2158-
auto flushPromise = lastFlush.addBranch().attach(kj::defer([this]() {
2159-
flushScheduled = false;
2160-
flushScheduledWithOutputGate = false;
2161-
})).then([this]() {
2158+
auto flushPromise = lastFlush.addBranch().attach(
2159+
util::DurationExceededLogger(
2160+
clock,
2161+
5 * kj::SECONDS,
2162+
kj::str("waiting on previous flushes took longer than expected", flushesEnqueued)
2163+
),
2164+
kj::defer([this]() {
2165+
flushScheduled = false;
2166+
flushScheduledWithOutputGate = false;
2167+
}))
2168+
.then([this]() {
21622169
++flushesEnqueued;
21632170
return kj::evalNow([this](){
21642171
// `flushImpl()` can throw, so we need to wrap it in `evalNow()` to observe all pathways.
@@ -2492,6 +2499,11 @@ kj::Promise<void> ActorCache::startFlushTransaction() {
24922499
}
24932500

24942501
kj::Promise<void> ActorCache::flushImpl(uint retryCount) {
2502+
auto durationAlert = util::DurationExceededLogger(
2503+
clock,
2504+
5 * kj::SECONDS,
2505+
"flushImpl took longer than expected"
2506+
);
24952507
KJ_IF_SOME(e, maybeTerminalException) {
24962508
// If we have a terminal exception, throw here to break the output gate and prevent any calls
24972509
// to storage. This does not use `requireNotTerminal()` so that we don't recursively schedule

0 commit comments

Comments
 (0)