feat(workflow-engine): add namespace throttle sweep state machine - #19964
Draft
danielskovli wants to merge 2 commits into
Draft
feat(workflow-engine): add namespace throttle sweep state machine#19964danielskovli wants to merge 2 commits into
danielskovli wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 19, 2026 12:45
2207cd8 to
8fa7487
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 06:47
8fa7487 to
61d785b
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 09:17
61d785b to
29efbff
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 09:32
29efbff to
1aed5f3
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 09:54
1aed5f3 to
dd3039e
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 11:49
dd3039e to
8796756
Compare
danielskovli
force-pushed
the
feat/workflow-engine-throttle-sweep
branch
from
August 20, 2026 12:05
8796756 to
3761082
Compare
NamespaceThrottleService runs the failure-storm circuit breaker's full detect → throttle → probe → release cycle under an advisory lock (single writer across replicas), parking Requeued populations behind jittered, retry-deadline-clamped throttled_until stamps while rotating canaries probe recovery, then releasing oldest-first in doubling cohorts. Each replica publishes an in-memory open-breaker snapshot (IThrottleStateView) per cycle for the upcoming handler cooperation; with Throttling.Enabled off the service exits before entering its loop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…xpire the breaker snapshot fail-open Two ADR review findings (PR #19954): a canary observed mid-attempt no longer counts as progressed — being leased proves nothing about the target, and in a hang-until-timeout storm counting it as progress would release cohorts into a hanging target that cannot feed the re-trip signal until its attempts time out. And the handler-facing open-breaker snapshot now carries its publication time and reads as empty once older than three sweep intervals, so a replica whose sweep loop has died loses its power to park instead of stamping workflows into long-closed namespaces with nothing left to clear them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The core of the namespace circuit breaker (#18481, ADR in #19954): a periodic sweep (
NamespaceThrottleService) running detect → throttle → probe → release under a Postgres advisory lock — single writer across replicas; a held lock skips the cycle rather than queueing. WithThrottling.Enabled=falsethe loop never starts.GROUP BY namespaceover the new partial index; trip = absolute floor AND ratio, both fromEngineSettings.Throttling.throttled_until = now + window(±20% jitter per row), clamped per-stamp to each workflow's current step's retry deadline — the anchor rule is extracted fromWorkflowHandlerinto a sharedStepExtensions.ResolveRetryAnchor(behavior-neutral) and combined with the existingGetDeadline; a row at/past its deadline is left unparked so the final attempt is never delayed. Stamps are guardedWHERE status = Requeuedand never touchupdated_at.backoff_untilRequeued workflows, unparked, judged purely by requeue-count comparison against counts recorded at selection (race-free vs. mid-attempt; a vanished canary counts as progressed). Unanimous failure → window ×2 (capped) + canary rotation; any progress → HalfOpen (quorum of one), first cohort releasing in the same sweep.now + random()·SweepInterval(jittered smear, not a NULL-clear, so a big cohort doesn't hit one poll cycle). Re-trip during recovery is evaluated over the unparked population only (parked rows are still Requeued — raw counts would re-trip instantly) and returns to Open keeping the grown window.throttled_untilis cleared, then is deleted. A re-trip from Closed starts over at the initial window — the grace period judged the incident over.IThrottleStateViewsingleton (refreshed by every replica each cycle, lock holder or not) exposing Open breakers only — HalfOpen is deliberately excluded so cooperative parking (next PR) cannot hide the failures the re-trip signal is judged on.engine.throttle.tripped/extended/released/closedcounters taggednamespace, an open-breakers gauge, per-cycle activity, and structured logs for every transition.Stacked on #19962.
Verification
🤖 Generated with Claude Code