Repository navigation
fix: key the spawn task id on the job, not the rule (#19) - #23
Merged
Merged
Conversation
task_id was smk-<rule>-<attempt>, so a wildcard fan-out's jobs shared one completion record and each was reported from whichever shard wrote last. Use smk-<rule>-<jobid>-<attempt>; truncate only the rule part.
Contributor
Author
Live verification: PASS (spore-host-dev, 2026-11-08)Setup.
One id and one record per shard: Completions are reported per job, one at a time, a few seconds after each record:
Cost: 4 × t4g.small for about 1.5–3 min each, all self-terminated. Leak check (us-east-1 and us-west-2, after teardown).
|
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 #19
Refs spore-host/spore-host#644 (pre-1.0 hardening).
Root cause
_task_idbuiltsmk-<job.name>-<attempt>, andjob.nameis the rule name. Every job of a wildcard fan-out therefore got the same id (e.g. fourstatsjobs →smk-stats-1). The id is both the instance name and the key oftasks/<id>/completion.json.check_active_jobspolls that one key for everySubmittedJobInfo, so with--jobs N > 1each job was reported from whichever shard's record was there at that moment. A failed shard could be reported as succeeded, or the reverse. Each new launch also clears the shared record (tasklaunch.clearStaleCompletion), which explains the delayed, batched completions measured in the issue comment.Fix
The id is now
smk-<rule>-<jobid>-<attempt>. This is the issue's suggested primitive:jobidis already in the dispatch log line.jobidis unique per DAG node within a run (e.g. 2–5 for fourstatsshards).jobidis unchanged and onlyattemptmoves. A retry gets a fresh record and never reads the previous attempt's, as before.-<jobid>-<attempt>suffix is always kept, so a long rule name can't truncate two jobs into one id again. Group jobs (UUID jobids) are sanitized to the same[a-z0-9-]alphabet.jobidis short and sufficient.Compatibility with existing records
smk-<rule>-<attempt>) are never read by the new code. Snakemake doesn't persist external job ids across a restart of the main process, so no in-flight job can straddle the upgrade.spawn-results-<acct>-<region>/tasks/smk-*. Nothing reads them and they can be deleted.stats_4attempt 1 (oldsmk-stats-4-1) and rulestats, jobid 4, attempt 1 (new). This is harmless:spawn task rundeletes any stale completion record for the id before launching (clearStaleCompletion), so a new job never reads an old record.jobidrestarts at 0 in each run, so two separate runs of the same workflow reuse ids, as they did before with rule names. That is safe for the same reason (launch clears the stale record). It only matters for concurrent runs of the same workflow under the same account and region, which were already unsafe and are no worse now.Tests
tests/test_task_id_per_job.py(6 tests) all fail onmainand pass with the fix. The key one drivesrun_jobfor four shards of one rule and thencheck_active_jobswith one shard's record failing, and asserts that exactly that shard errors. Full suite: 50 passed.ruff checkandmypyare clean.The engine-composition test's seeded id changes to
smk-noout-0-1: the only job of a one-job DAG is jobid 0, confirmed withsnakemake -n. The Composition CI job on this PR exercises it against Substrate.Before merge
A live fan-out (the cookbook Shape-F recipe,
--jobs 4) is worth running. Expect onetasks/smk-stats-<jobid>-1/prefix per shard, and completions reported per job rather than in batches.