Repository navigation
Conversation
|
Thank you for contributing this, @MaxonT! PR #909: an earlier fix for the same issue already fixed a case that this change doesn't have. This PR's new condition keeps replay status for a virtual child that is the first operation in its context. When a replayed operation comes before the virtual child, context.py:632, the check that runs after each operation looks for a checkpoint at the virtual child's own id. A virtual child never has one, so the check switches the context to NEW before the virtual child starts. Inside a virtual child that follows a replayed step or another virtual child, The final commit of that PR fixes this by making |
Hi there, this patch is for the virtual child context handling in the durable execution SDK, so replay no longer ends early and resumed operations still get their notifications; please check the replay case.
Issue #, if available
Fixes #889
Description of changes
When the context is replaying,
DurableContext._replay_awareflips it to NEW before an operation whose own checkpoint does not exist. A virtual child never checkpoints itself (_run_in_child_contextpassesis_virtual, and the container is rejected if a checkpoint exists), so that rule always fires for it. The parent flips to NEW,create_child_contextcopies NEW into the child, and the child's existing inner operations then skip the replay and update hook gate.is_replaying()is wrong inside the child, plugins misson_operation_endfor an inner operation that completed during suspension, and the durable logger stops de-duplicating.The change: for a virtual child, the "brand-new operation" flip applies only when the container has no checkpoint and the child's first inner operation (
OperationIdNamespace(operation_id).create_id_for_step(1), the idcreate_child_contextgives its first operation) has no checkpoint either. Nothing else in_replay_awarechanges. Map and parallel virtual branches already keep REPLAY inConcurrentExecutor; this bringsrun_in_child_context(..., is_virtual=True)in line with them.Design
Not needed: no new option and no public API change.
context.py, no public API members.Assumptions
create_child_context(prefix is the container operation id). Evidence:identifier.pyandcontext.pyin this diff's context; the new test builds the inner id throughcreate_child_context(..., is_virtual=True)and not through the new code path, so it would fail if the two disagreed.Decisions not covered by the issue or the design note
_replay_awarecalls._set_replay_status_newor to the post-operation flip: the existing check against the parent's next operation still applies after the virtual child returns.Tests
test_virtual_child_keeps_replay_status_while_inner_history_exists: before the fix it fails withassert [False] == [True]; with the fix it passes.test_virtual_child_without_inner_history_starts_new: covers the branch that keeps the old behaviour. Mutation check: replacing the new lookup withFalsefails the first test, and forcingbrand_new = Falsefails the second.packages/aws-durable-execution-sdk-python/tests: 2283 passed, 2 failed (state_test.py::test_collect_batch_wakes_for_refresh_before_poll_intervaland::test_collect_batch_adds_refresh_that_comes_due_during_async_window, timing tests). I re-ran the first on the unchanged base commit and it fails there too; I did not compare the second against base separately.ruff checkandruff formatpass on the two touched files.hatch run types:check, and any run against a deployed function.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.