Repository navigation
fix: leave replay mode once an operation completed during suspension is consumed - #895
pcbeingused333 wants to merge 1 commit into
Conversation
…is consumed DurableLogger suppresses logs while the context is replaying, but the context only left replay mode when starting an operation with no checkpoint. If the last checkpointed operation (wait/callback) completed while suspended, the context stayed in replay and dropped the handler's new logs after it. Fixes aws#859 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| && durableContext.isReplaying() | ||
| && executionManager.isOperationUpdatedSinceLastInvocation(getOperationId())) { | ||
| durableContext.setExecutionMode(); |
There was a problem hiding this comment.
Codex AI review · Finding arf_v1_vh7pvlq3cnto2tiea4ujgg62dy
[P2] Keep replay transitions local to the consuming context
durableContext identifies the operation's creator, but ExecutionManager.waitForOperationCompletion() permits another context to await its future. When a replaying child consumes a parent-owned callback completed during suspension, this switches the parent's flag while leaving the child's flag unchanged. The parent can emit duplicate logs while still replaying, and fresh child logs remain suppressed, violating ADR-004's per-context replay isolation. Apply the transition to the context consuming the future and add a cross-context suspension regression asserting both contexts' replay states.
To suppress repeats, reply /ai verdict deferred, /ai verdict false-positive, or /ai verdict out-of-scope on the first nonblank line. Add rationale on later lines. A new /ai verdict accepted allows future repeats again.
| import software.amazon.lambda.durable.testing.LocalDurableTestRunner; | ||
|
|
||
| /** The context must leave replay mode once the first operation that completed during suspension is consumed. */ | ||
| class ReplayModeAfterSuspensionTest { |
There was a problem hiding this comment.
Codex AI review · Finding arf_v1_cusqr2xcutrqallsrwjbwtztqe
[P2] Approach: include the required unit regression coverage
AGENTS.md's Testing Requirements and CONTRIBUTING.md's pull-request requirement 3 require related unit tests, with integration tests added for cross-component behavior. This PR supplies only integration tests and explicitly reports “Unit Tests: No.” The shared replay transition therefore lacks the required isolated regression coverage. Under rule 9, return to the design phase described in rule 8 and revise the validation plan to include unit regressions alongside these integration scenarios.
To suppress repeats, reply /ai verdict deferred, /ai verdict false-positive, or /ai verdict out-of-scope on the first nonblank line. Add rationale on later lines. A new /ai verdict accepted allows future repeats again.
| // invocation. Once its result is consumed, the code that follows is no longer a replay, so leave | ||
| // replay mode and stop suppressing the handler's logs. | ||
| if (replayCompletedOperation.get() | ||
| && durableContext.isReplaying() |
There was a problem hiding this comment.
Codex AI review · Finding arf_v1_y2jsi7yzsi6fvzulsfofhh76yn
[P3] Approach: justify each retained condition under rule 4
Rule 4 requires an assertion-sensitive test for every new condition. Removing durableContext.isReplaying() cannot change the resulting state: setExecutionMode() only assigns false, including when the context already holds false. The guard therefore adds a condition without observable behavior that needs it. Under rule 9, return to the design phase described in rule 8 and simplify the transition around conditions with demonstrable behavioral requirements.
To suppress repeats, reply /ai verdict deferred, /ai verdict false-positive, or /ai verdict out-of-scope on the first nonblank line. Add rationale on later lines. A new /ai verdict accepted allows future repeats again.
Codex AI reviewThree findings: replay isolation and Rule 4 issues at Static review only; tests were not executed. Real-service Reviewed commit |
Fixes #859
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue Link, if available
#859
Description
DurableLoggerdrops the handler's logs written after awaitor a callbackget()that completed while the execution was suspended: the context stays in replay mode for the rest of the invocation, soshouldSuppressreturns true for new code.Demo/Screenshots
N/A
Design
execute()when a replayed operation is inupdatedOperationIdsis the same size, but it is wrong forwaitAsync→step→get(): the intermediate step is still a replay and its logs must stay suppressed (covered bywaitAsyncThenStep_intermediateStepStaysReplay). ChangingExecutionManager's global mode was rejected becauseDurableExecutorand the plugin hooks read it.DurableContextImpl.isReplayingonly becomes false when an operation with no checkpoint starts (BaseDurableOperation.execute()). An operation that completed during suspension is replayed as terminal, so if it is the last checkpointed operation of the context, the context never leaves replay mode.BaseDurableOperation.waitForOperationCompletion(); no public API change.Assumptions
updatedOperationIdsin the invocation input lists the operations that changed since the previous successful invocation (documented inDurableExecutionInput). Consequence: after a failed invocation, logs from the retried section can be emitted again. Behavior against the real service: unverified (tests useLocalDurableTestRunner, which fillsupdatedOperationIds).Decisions not covered by the issue or the design note
get()), not when the operation is replayed, so code between an async start and itsget()keeps the replay behavior.Checklist
sdk+sdk-integration-testssuite were run by the AI tool (see Testing)Testing
Unit Tests
No.
Integration Tests
Yes,
ReplayModeAfterSuspensionTest(sdk-integration-tests,LocalDurableTestRunner): code after a wait that completed during suspension is not a replay; same aftercallback.get();waitAsync→step→get()keeps the step in replay and leaves it afterwards. On main all 3 fail (expected: <[false]> but was: <[true]>;expected: <[middle=true, after=false]> but was: <[middle=true, after=true]>); with the fix they pass, and the fullsdk+sdk-integration-testssuite passes.Examples
Not applicable.
This change was prepared with the assistance of an AI tool (Claude Code); the submitter has not manually reviewed or run it.