Repository navigation
feat(sdk): add experimental pause from a retry decision - #938
Open
ParidelPooya wants to merge 1 commit into
Open
ParidelPooya wants to merge 1 commit into
ParidelPooya wants to merge 1 commit into
Conversation
A retry decision can now ask the SDK to pause the execution after a failed step attempt. The step saves its RETRY checkpoint, calls PauseDurableExecution, and ends the invocation as PENDING. After ResumeDurableExecution, the step runs its next attempt. - RetryDecision.retry(delay, pause) and shouldPause(). - pauseEvery overloads on the exponential, linear and fixed-delay retry strategies. They keep the configured delay and jitter. - DurableExecutionClient.pauseExecution, a default method that throws UnsupportedOperationException. The Lambda client calls PauseDurableExecution with a SHA-256 ClientToken of the execution ARN, the step id and the attempt. A failed or unsupported pause logs a warning and the step retries as usual. - The local in-memory client pauses the local execution, so the local test runner pauses and resumes. - An AT_MOST_ONCE attempt interrupted by an earlier invocation does not pause. - Docs for permissions, behavior and the local test runner. All new public APIs are marked experimental.
This branch has not been deployed
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.
Closes #897
What
A retry decision can ask the SDK to pause the execution after a failed step attempt. The step saves its RETRY checkpoint, calls
PauseDurableExecution, and ends the invocation as PENDING. AfterResumeDurableExecution, the step runs its next attempt. This matches the JavaScript, Python, Go and Rust SDKs.Why (design note)
RetryDecisionhas onlyshouldRetryanddelay, andDurableExecutionClienthas no pause call.RetryStrategy. It duplicates the retry decision and lets the two disagree.pauseflag on the existing retry decision, pluspauseEveryoverloads of the existing strategy factories. This adds no second decision path.pauseflag onRetryDecision. It is the smallest change and the same shape as the other SDKs.Behavior
PauseDurableExecution, then the invocation ends as PENDING.RetryDecision.retry(delay, pause)andshouldPause()are new.pauseEveryoverloads exist onexponentialBackoff, bothlinearBackoffforms andfixedDelay. They pause on attemptspauseEvery,2 * pauseEvery, and so on, and keep the configured delay and jitter. ApauseEveryof 0 or less never pauses.DurableExecutionClient.pauseExecutionis a default method that throwsUnsupportedOperationException. A custom client that does not override it keeps today's behavior: a warning, then a normal retry.ClientTokenis the SHA-256 hex ofpause:<execution ARN>:<step operation id>:<attempt>.AT_MOST_ONCEattempt interrupted by an earlier invocation does not pause. Only a failure thrown by the step function in this invocation can pause.LocalDurableTestRunner.runUntilComplete()returns PENDING andresumeExecution()continues.docs/core/steps.mdcovers behavior, permissions (lambda:PauseDurableExecution, andkms:Decryptwith a customer managed key) and the local runner.Decisions the issue did not cover
pauseExecutionis a default method onDurableExecutionClient, so existing custom clients still compile.Step "<name or id>" failed attempt <n>.withRetryignorespause, as in the other SDKs. The submitter step ofwaitForCallbackpauses, because it runs as a step with itsstepConfig.parallelormapbranch stops, and after the resume an at-least-once step runs again. This is documented and covered by an integration test.ObservedClientinlmi-testsdelegatespauseExecutionand traces it.pauseEvery, as for the other retry options.CONTRIBUTING.md. A conformance test for pause on retry may be worth adding in the conformance repository.Tests
RetryDecisionTest,RetryStrategiesTest: the flag, everypauseEveryoverload, jitter kept, non-positive values.StepOperationPauseTest: RETRY checkpoint, then pause, then suspension (in order), pause failure falls back to retry, no pause without the flag, no pause for an interruptedAT_MOST_ONCEreplay, unnamed step label, token stable and unique per execution, step and attempt.LambdaDurableFunctionsClientTest,LocalMemoryExecutionClientTest,ObservedClientTest: the client side.PauseOnRetryIntegrationTest(local runner): pause, resume and continue with an explicit pause decision and withpauseEvery, plus a pause in oneparallelbranch while a sibling runs.sdk,sdk-testing,sdk-integration-testsandlmi-tests.spotless:checkis clean.Unverified
Review rounds
Each round used a new independent reviewer that saw only the diff, the issue and the repository rules.
linearBackoffwith jitter and for token uniqueness. The behavior is now documented and tested, and both tests were added.ObservedClientdid not delegatepauseExecution, a dead condition inwithPauseEvery, missing@apiNotemarkers, and tests for an unnamed step and for the sibling behavior. All fixed.try/catchwas rejected, because the checked exception must be handled and the 64-character token matches the other SDKs.withRetryignorespause. Fixed.