Skip to content

fix(orchestration): take the resubmit lock with O_EXCL, not mkdir - #4973

Merged
marcromeyn merged 1 commit into
mainfrom
mromeijn/fix-resubmit-lock
Oct 23, 2026
Merged

marcromeyn merged 1 commit into
mainfrom
mromeijn/fix-resubmit-lock

Conversation

@marcromeyn

@marcromeyn marcromeyn commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Evidence (Ubuntu 26.04, two-way races of the bare primitive):

Lock primitive Trials Both "won"
uutils mkdir 0.8.0 (/usr/bin/mkdir) 300 7
GNU mkdir (/usr/bin/gnumkdir) 300 0
bash set -o noclobber; : > lock 600 0

A traced failing run showed both resubmit scripts reporting the lock taken, on the same lock inode, before both reached sbatch.

No separate issue: the failure analysis is above and in the #swdl-nemo-gym-core-devs thread.

Test plan

  • New regression test test_held_lock_refuses_a_resubmit_even_when_mkdir_is_not_exclusive: a mkdir stub on PATH never reports an existing directory; a held lock must still refuse the resubmit and queue nothing. Fails on main (DID NOT RAISE), passes with this change.
  • test_two_concurrent_resubmits_queue_one_job under coverage on 2 CPUs (closest local match to CI): main 2/16 failed; this change 0/16, plus 40/40 under 8-way parallel load.
  • pytest tests/unit_tests/test_eval_resubmit.py: 25 passed.
  • pytest tests/unit_tests -k "resubmit or orchestration or slurm": 505 passed, 15 skipped (two modules needing the mlflow/telemetry extras ignored locally).
  • pre-commit run --files nemo_gym/orchestration/executors/slurm.py tests/unit_tests/test_eval_resubmit.py passes.
  • DCO sign-off.
  • CI Nemo_CICD_Test green (run 39946012640, ubuntu-26.04).

Rollout evidence: N/A. This changes the Slurm resubmit lock primitive only; no agent, verifier or model behavior changes. Not exercised against a live Slurm cluster.

Generated with Devin

`gym eval resubmit` serializes concurrent resubmits of one job dir with
`mkdir .gym_resubmit.lock`. Ubuntu 26.04 ships uutils coreutils as its
default, and its mkdir (0.8.0) can report success to two processes that
create the same directory concurrently: 7 of 300 two-way races both
"won", against 0 of 300 for GNU mkdir. Two resubmits could then both
queue a job for one run, and test_two_concurrent_resubmits_queue_one_job
failed intermittently on the ubuntu-26.04 CI runners.

Create the lock as a file with bash's noclobber instead. bash opens it
with O_CREAT|O_EXCL itself, so atomicity no longer depends on the
coreutils implementation, and O_EXCL remains atomic on the shared
filesystems (NFSv3+, Lustre) that motivated avoiding flock. A lock
directory left by an earlier Gym still blocks the redirect, so upgrading
mid-resubmit stays safe.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Marc Romeyn <[email protected]>
@marcromeyn marcromeyn added bug Something isn't working area:orchestration Job submission, deployment, services, and lifecycle management labels Oct 23, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@marcromeyn

Copy link
Copy Markdown
Contributor Author

/ok to test b4aa00f

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 23, 2026 11:26
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 23, 2026
@AdamRajfer
AdamRajfer self-requested a review October 23, 2026 12:29
@marcromeyn
marcromeyn added this pull request to the merge queue Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39954790978

This branch was previously deployed

1 inactive deployment
public — b4aa00f1 Deployed Oct 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #6778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants