One pull at a time: the run is claimed in the database and its marker rides in each batch
A second pull (schedule, Run button, `app job pull` in another process) could start while one was fetching and overwrite the stored run marker, so the first run's boards failed their stamp check or a settle closed on the other run's id lists. `claim_run` sets `pull:run` in one conditional statement, only while it equals `pull:settled` or is older than an hour; a refused `pull` job queues no stage and says so in its result and a notice, and the CLI exits 1. Batches carry the marker in their payload, the plugins stamp with it, and the settle reads it off its own batches' payloads before releasing the run. Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
1 parent
c7da12b93d
commit
b43fc54565
11 files changed
+328
-70
No files matched your search
+11
-2
@@ -176,8 +176,17 @@ def run_job(args: argparse.Namespace) -> int:
|
||||
bootstrap=jobs.BOOTSTRAP, bootstrap_arg=str(config.path or ""),
|
||||
tz=config.timezone, schedules=False)
|
||||
if chained or args.kind not in JOBS:
|
||||
task_id = queue.start_task(cascade.chain(args.kind) if chained
|
||||
else TASKS[args.kind]())
|
||||
first = cascade.chain(args.kind) if chained else TASKS[args.kind]()
|
||||
if args.kind == "pull":
|
||||
# The same claim the `pull` job makes, so a pull here and one in
|
||||
# the server's worker cannot both fetch.
|
||||
run = jobs.pull.claim_run(store)
|
||||
if not run:
|
||||
print(json.dumps({"task": "pull", "result": jobs.pull.ALREADY_RUNNING,
|
||||
"running": jobs.pull.running(store)}))
|
||||
return 1
|
||||
first = cascade.pull_chain(run)
|
||||
task_id = queue.start_task(first)
|
||||
queue.drain()
|
||||
started = queue.jobs.of_task(task_id)
|
||||
if not started:
|
||||
|
||||
Reference in new issue
Block a user