Repository navigation
Conversation
This was referenced Oct 15, 2026
Merged
…ata by run (#943) pipeline_id comes from the definition file, so launching it twice reused it. Store.Put was an unconditional PutItem: the second launch replaced the running pipeline's record with an empty INITIALIZING one, orphaning its instances, and two orchestrator chains then ran against one record. Markers and outputs were keyed by s3_prefix alone, so a second run found the first run's COMPLETE (or FAILED) markers and its dependents read the first run's outputs. Store.Put is now a conditional create (absent or terminal), returning *ActiveRunError otherwise. `spawn pipeline launch` refuses over a run in flight; --replace cancels that run (SetCancelRequestedForRun, conditional on its run id), waits up to 5 minutes for it to finish, and then Replace()s it, conditional on it still being that run. Every launch gets a run id (UTC time + 32 random bits, crypto/rand). RunKeyPrefix puts a run's markers, outputs and stage config under <s3_prefix>/runs/<run-id>; the CLI's definition copy is per run too. The orchestrator uses state.DataPrefix() for every key and writes it as the spawn:s3-prefix tag, so the runner (of any version) stays inside its run. Records without a run id keep the old layout. The orchestrator's save is conditional on its run id and returns errSuperseded otherwise; a chain that finds the record moved to another run terminates its own instances, cleans up its groups and stops; an invocation for a replaced run exits. Network group names carry the run id so a replacement cannot collide with a run still deleting its own. Tests fail against compiling reverts of each guard (unconditional put, save and cancel; DataPrefix = S3Prefix; no supersede/invocation check; --replace without cancel; group name without run id), including an end-to-end run of the real spored against stale outputs. (#943)
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Fixes #943
Stacked on #957 (fix/929). This PR's base is
fix/929. Merge in order: #931, #942, #957, then this.Cost safety. Found by reading the code, then tested with fakes and the in-process Substrate emulator. No AWS resources were created, nothing was launched and nothing was deployed.
What was wrong
pipeline.Store.Putwas an unconditionalPutItem.pipeline_idcomes from the definition file, so launching the same file again while its run was in flight replaced that run's record with an emptyINITIALIZINGone. The running orchestrator chain reloaded a record that no longer listed its instances, and two chains then ran against one record. Each chain's save was also an unconditionalPutItem, so they overwrote each other.<s3_prefix>/stages/<stage>/…. A second run under the same prefix found the first run'sCOMPLETEand completed its stages before they had done anything. Its dependents downloaded the first run's outputs, and a staleFAILEDfailed a fresh run. The CLI's copy of the definition (spawn-pipelines-<region>/pipelines/<id>/config.json) was also overwritten by the second launch, and the first run's orchestrator re-reads that copy on every cold start.What changed
Refuse, or replace explicitly.
Store.Putis a conditional create:attribute_not_exists(pipeline_id) OR status IN (COMPLETED, FAILED, CANCELLED). Otherwise it returns*pipeline.ActiveRunError. DynamoDB evaluates the condition, so two concurrent launches cannot both pass it. A finished pipeline can still be launched again.spawn pipeline launchrefuses over a run in flight and explains the options: wait,spawn pipeline cancel, or--replace.--replacesends a cancel aimed at that run only (SetCancelRequestedForRun, conditional on its run id). It waits up to 5 minutes for the run's own orchestrator to terminate its instances and mark itCANCELLED, thenReplaces the record, conditional on it still being that run.--replaceand not--force. [audit] Flags: execute-vs-dry-run is --force (cleanup) vs --confirm (workspace-destroy) vs --dry-run (capacity-block) #315 retired--forcefrom this CLI because the word meant different things on different commands (cleanup,upgrade-spored).--replacesays what it does.Run ids.
crypto/rand, e.g.20261015t120000z-1a2b3c4d. It is printed at launch, stored asrun_id, and sent in the Lambda event.pipeline.RunKeyPrefixputs a run's markers, outputs and stage config under<s3_prefix>/runs/<run-id>/. The orchestrator builds every key fromstate.DataPrefix().spawn:s3-prefixtag. So the runner stays inside its run whatever its version: the deployed spored needs no change. It also adds aspawn:run-idtag, and exportsSPAWN_S3_PREFIX(the run's prefix) andSPAWN_RUN_IDto the stage.collectreads only the run in the record.<s3_prefix>/*, which coversruns/.One chain per record.
run_id = :run, orattribute_not_exists(run_id)for a legacy record). OnConditionalCheckFailedit returnserrSupersededand does not retry.run_idis not the record's exits before doing anything.Tests (each watched failing against a revert that compiles)
Put/Replacewithout the conditionTestPutRefusesToReplaceARunInFlight,TestReplaceOverwritesOnlyTheRunItCancelled,TestLaunchOverARunInFlightIsRefused,TestLaunchReplaceCancelsTheOldRunFirstDataPrefix()returnsS3PrefixTestTwoRunsUnderOnePrefixShareNoKeys,TestStaleMarkersFromAnotherRunDoNotDecideThisOne,TestStageInstancesAreLaunchedIntoTheirRun,TestStageRunnerEndToEnd_StaysInsideItsRun(the real spored, against stale outputs left at both the old keys and another run's)TestSaveDoesNotOverwriteAnotherRunsRecord(Substrate, which enforces condition expressions)pollOnceTestReplacedRunTerminatesItsInstancesAndStopshandlerTestInvocationForAReplacedRunExitsTestCancelForRunOnlyCancelsThatRun--replaceskips the cancelTestLaunchReplaceCancelsTheOldRunFirstTestStageInstancesAreLaunchedIntoTheirRunmake check: everything passes exceptTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, the known Docker-only failure (no daemon here).make check-nested: all 9 nested modules clean.go test ./lambda/pipeline-orchestrator/ ./pkg/pipeline/(not-short): pass.Deploy
spawn-pipeline-orchestrator(make -C lambda/pipeline-orchestrator deploy, infra account). It needs no new IAM.The two can go in either order:
Caveats
--replacewaits for the cancel first so that this happens only if the old orchestrator is not making progress at all.--replaceneeds the CLI's credentials to read and update the record. The CLI already reads and writes it.s3:DeleteObject). If that is not permitted, the object is left behind, which is harmless.