Skip to content

fix issue 148 - sub-orchestrations cannot reuse existing instance ids - #330

Open
Usein Mambediiev (usemam) wants to merge 7 commits into
microsoft:mainfrom
usemam:fix-issue-148
Open

Usein Mambediiev (usemam) wants to merge 7 commits into
microsoft:mainfrom
usemam:fix-issue-148

Conversation

@usemam

Copy link
Copy Markdown
Contributor

Fixes #148

Terminal targets (Completed/Failed/Terminated) are now purged via the existing PurgeInstanceStateByID before the insert, mirroring CreateInstance's overwrite path. Active instances are untouched.

Tests

Re-enabled the disabled RetryFailedSubOrchestration(true) case; added ReuseCompletedSubOrchestrationID and CannotRecreateRunningSubOrchestrationInstance.

@usemam

Copy link
Copy Markdown
Contributor Author

Chris Gillum (@cgillum) could please take a look? Thank you.

@andystaples andystaples left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two P1 data-consistency issues in the new sub-orchestration instance-ID reuse path:

  1. A concurrent checkpoint can purge another parent's newly active child execution.
  2. A duplicate checkpoint can commit a purge and restart of a completed child even though checkpoint deduplication raises an error.

Both issues were reproduced against this PR's SQL in an isolated SQL Server 2022 database. For the second issue, the same replay against the merge-base SQL preserves the completed child's status and history. The inline comments include the failure sequences and requested changes.

@usemam

Copy link
Copy Markdown
Contributor Author

Hi andystaples
Sorry to bother. Just wanted to follow up if you had a chance to take a look at my fixes for the concerns you voiced in your review of this PR?
Thank you!

@andystaples andystaples left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for a stale child checkpoint that can overwrite a newly reused execution.


IF EXISTS (SELECT 1 FROM @SubOrchestrationsToRecreate)
BEGIN
EXEC __SchemaNamePlaceholder__.PurgeInstanceStateByID @SubOrchestrationsToRecreate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Reject stale child checkpoints after reusing an instance ID

Purging the completed child's history removes the duplicate-checkpoint protection for its previous execution. If a delayed checkpoint from that execution arrives after the child has been recreated, _CheckpointOrchestration treats the execution ID mismatch as ContinueAsNew. It deletes the new execution's history and writes the old execution ID and status back to Instances, while the new ExecutionStarted event remains queued. The new child can be stranded, and any history it has already written can be lost.

Please prevent checkpoints for a previous execution from modifying the replacement while preserving legitimate ContinueAsNew behavior, and add a regression that checkpoints the old child after its ID is reused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub-orchestrations cannot reuse existing instance IDs

2 participants