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
2 changes: 2 additions & 0 deletions src/workerd/api/global-scope.c++
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ kj::Promise<WorkerInterface::AlarmResult> ServiceWorkerGlobalScope::runAlarm(
}
return WorkerInterface::AlarmResult {
.retry = true,
.retryCountsAgainstLimit = !context.isOutputGateBroken(),
.outcome = outcome
};
}).then([&context](WorkerInterface::AlarmResult result) -> kj::Promise<WorkerInterface::AlarmResult> {
Expand All @@ -411,6 +412,7 @@ kj::Promise<WorkerInterface::AlarmResult> ServiceWorkerGlobalScope::runAlarm(
}
return WorkerInterface::AlarmResult {
.retry = true,
.retryCountsAgainstLimit = false,
.outcome = EventOutcome::EXCEPTION
};
});
Expand Down
8 changes: 8 additions & 0 deletions src/workerd/io/io-context.c++
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ kj::Maybe<IoOwn<kj::Promise<void>>> IoContext::waitForOutputLocksIfNecessaryIoOw
});
}

bool IoContext::isOutputGateBroken() {
KJ_IF_MAYBE(a, actor) {
return a->getOutputGate().isBroken();
} else {
return false;
}
}

bool IoContext::isInspectorEnabled() {
return worker->getIsolate().isInspectorEnabled();
}
Expand Down
6 changes: 6 additions & 0 deletions src/workerd/io/io-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ class IoContext final: public kj::Refcounted, private kj::TaskSet::ErrorHandler
//
// Use the ...IoOwn() overload if you need to store this promise in a JS API object.

bool isOutputGateBroken();
// Check if the output gate (only used by actors) is currently broken. This indicates that there
// was a problem with committing storage writes.
//
// For non-actor requests, this always returns false.

template <typename T>
kj::Promise<T> lockOutputWhile(kj::Promise<T> promise);
// Lock output until the given promise completes.
Expand Down
4 changes: 4 additions & 0 deletions src/workerd/io/io-gate.c++
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ kj::Promise<void> OutputGate::onBroken() {
}
}

bool OutputGate::isBroken() {
return brokenState.is<kj::Exception>();
}

void END_OUTPUT_LOCK_CANCELATION_STACK_START_WAITER_STACK() {}

kj::Exception OutputGate::makeUnfulfilledException() {
Expand Down
2 changes: 2 additions & 0 deletions src/workerd/io/io-gate.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ class OutputGate {
//
// This method can only be called once.

bool isBroken();

private:
Hooks& hooks;

Expand Down
1 change: 1 addition & 0 deletions src/workerd/io/worker-interface.c++
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ kj::Promise<WorkerInterface::AlarmResult> RpcWorkerInterface::runAlarm(kj::Date
auto respResult = resp.getResult();
return WorkerInterface::AlarmResult {
.retry = respResult.getRetry(),
.retryCountsAgainstLimit = respResult.getRetryCountsAgainstLimit(),
.outcome = respResult.getOutcome()
};
});
Expand Down
3 changes: 2 additions & 1 deletion src/workerd/io/worker-interface.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct ScheduledRun @0xd98fc1ae5c8095d0 {
struct AlarmRun @0xfa8ea4e97e23b03d {
outcome @0 :EventOutcome;

retry @1 : Bool;
retry @1 :Bool;
retryCountsAgainstLimit @2 :Bool = true;
}

interface EventDispatcher @0xf20697475ec1752d {
Expand Down
1 change: 1 addition & 0 deletions src/workerd/io/worker-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class WorkerInterface: public kj::HttpService {

struct AlarmResult {
bool retry = true;
bool retryCountsAgainstLimit = true;
EventOutcome outcome = EventOutcome::UNKNOWN;
};

Expand Down