Draft
Conversation
Add `GetVersionInterleavedUpdateReplayTest` under `versionTests` and capture a representative history in `testGetVersionInterleavedUpdateReplay.json`. The test reproduces issue #2796 against an external Temporal service by starting the workflow before polling, interleaving `WORKFLOW_EXECUTION_UPDATE_COMPLETED` between two version markers, evicting the workflow cache, and triggering replay with a follow-up update. Assert the observed worker failure shape on replay: `WORKFLOW_WORKER_UNHANDLED_FAILURE` with `IllegalStateException` containing `Premature end of stream`. Keep the captured history for debugging and follow-up lower-level replay coverage. `WorkflowReplayer` does not fail on the full history alone, so this remains a live external-service repro rather than a replay-only regression.
Add `GetVersionInterleavedUpdateReplayTaskHandlerTest` to reproduce the underlying stale-history replay failure from issue #2796 without relying on an external Temporal service. The test loads the captured interleaved history, reconstructs the accepted update protocol message, feeds `ReplayWorkflowTaskHandler` a synthetic workflow task for the failing WFT, and mocks `WorkflowServiceStubs` to return a stale full-history view ending before the task's started event. Assert the current failure shape directly: `WORKFLOW_WORKER_UNHANDLED_FAILURE` with `IllegalStateException: Premature end of stream, expectedLastEventID=11 but no more events after eventID=9`. This complements the live external-service repro by isolating the lower-level handler path that turns stale history into a replay failure.
Contributor
|
Didn't take a look at the code, just reading the PR description
That was the intended behaviour, if the server returns a stale history we want to fail the workflow task and try again with a fresh workflow task. A stale history is basically garbage and shouldn't be trusted. Failing a workflow task should be idempotent and not effect replay so it isn't clear how this behaviour could be related to a NDE. |
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.
What was changed
This PR fixes stale-history handling in worker replay.
When the worker received a partial or empty workflow task and fetched "full history" from the service, the SDK could accept a stale history read that did not actually reach the polled task's
startedEventId. Replay would then fail later and be reported as a workflow task failure.The fix changes replay handling to:
WORKFLOW_TASK_FAILED, (Reviewers please chime in on this) @temporalio/sdkWhy?
The original failure was observed while replaying histories where
WorkflowExecutionUpdateCompletedevents were interleaved betweengetVersionmarkers, which made the issue look like agetVersionnondeterminism bug. The deeper issue was more general: live worker replay could run against a stale "full history" read from the service.That meant valid histories could fail replay only because the worker was given incomplete history for the polled workflow task. The SDK should recover from that condition instead of failing the workflow task as an unhandled worker error.
Checklist
Closes Replay fails: UpdateCompleted events between version markers breaks replay #2796
How was this tested:
./gradlew --offline :temporal-sdk:test --tests "io.temporal.internal.replay.ReplayWorkflowRunTaskHandlerTaskHandlerTests" --tests "io.temporal.internal.replay.GetVersionInterleavedUpdateReplayTaskHandlerTest"USE_DOCKER_SERVICE=true ./gradlew :temporal-sdk:test --tests "io.temporal.workflow.versionTests.GetVersionInterleavedUpdateReplayTest"Test coverage now includes:
WORKFLOW_TASK_FAILED,getWorkflowExecutionHistory(...)to return truncated history on the first call and complete history on retry,No, bugfix only.