Repository navigation
fix: Virtual child contexts exit replay early and omit resumed operation notifications #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nandanadileep
wants to merge
2
commits into
aws:main
Choose a base branch
from
nandanadileep:oss-harness/issue-889
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a virtual child that is the first operation in its context, but not one that comes after a replayed operation. After each operation, context.py:626, the look-ahead switches the context to NEW when context.py:522-524,
_next_operation_exists()finds no checkpoint at the next operation's id. A virtual child never has a checkpoint at its own id. So when a replayed operation comes before it, the context is already NEW by the timerun_in_child_contextreaches this condition, and the child runs as NEW. Can_next_operation_exists()also check the first operation inside the next one, as the JS SDK does?Two things I checked support this:
DurableFunctionTestRunnerand a plugin, I ran a handler that calls a step and then a virtual child that waits. On the resumed invocation it behaves as onmain:is_replaying()returnsFalseinside the child, and the plugin gets noon_operation_endfor the wait. The second of two virtual children in a row fails in the same two ways. When the virtual child is the first operation, this branch makesis_replaying()returnTrueand delivers theon_operation_end.checkAndUpdateReplayModealso checks the first child id,${pendingStepId}-1.This is the change I tested on top of this branch:
With it, the core unit and e2e tests pass, and both handlers above get the right
is_replaying()andon_operation_end. The second read is an in-memory lookup. It runs only while replaying, when the next operation has no checkpoint at its own id. One case is still not covered: after a replayed operation, the context still switches to NEW before a virtual child that has no checkpoint at its first inner id, such as an empty one. JS has the same limit, so I think that can stay out of this PR.Can the context.py:543-552,
_replay_awaredocstring also describe the virtual case? It still says that a next operation without a checkpoint switches the context to NEW, both before and after the operation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 84b7b61.
_next_operation_exists()now also checks the first inner id viaOperationIdNamespace(...).create_id_for_step(1), matching the JS SDK. The_replay_awaredocstring now describes that virtual case.Kept the
is_virtualbefore-op guard: it is still needed when the virtual child is the first operation in its context._next_operation_exists()only runs after a previous operation, so it cannot cover that first-op path.