Repository navigation
fix(orchestration): take the resubmit lock with O_EXCL, not mkdir - #4973
Merged
Merged
Conversation
`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]>
Contributor
Author
|
/ok to test b4aa00f |
AdamRajfer
self-requested a review
October 23, 2026 12:29
AdamRajfer
approved these changes
Oct 23, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39954790978 |
This was referenced Oct 23, 2026
This branch was previously deployed
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.
Summary
gym eval resubmitserializes concurrent resubmits of one job dir withmkdir .gym_resubmit.lock. Ubuntu 26.04 ships uutils coreutils as its default, and itsmkdir(0.8.0) can report success to two processes that create the same directory concurrently. Two resubmits can then both queue a job for one run.tests/unit_tests/test_eval_resubmit.py::test_two_concurrent_resubmits_queue_one_jobfails intermittently ([True, True] == [False, True]) on theubuntu-26.04runners: onmainat754c2f6c3, on test(terminus-2): clear PROMPT_COMMAND before the interrupt-exit scenario #4966's merge-queue run, and on feat(eval): extend generic slice metrics and preserve HLE labels #4658, Yoav miron/speed bench all splits preparation #4929, fix(mcp): support MCP 1 and 2 tool exposure #4567 and test(terminus): wait for the foreground job before interrupting it #4956. It is also a real bug for users whose Slurm login node runs Ubuntu 26.04.noclobber. bash opens it withO_CREAT|O_EXCLitself, so atomicity no longer depends on the coreutils implementation, andO_EXCLstays atomic on the shared filesystems (NFSv3+, Lustre) that motivated avoidingflock. The exit trap removes it withrm -f. A lock directory left by an earlier Gym still blocks the redirect (Is a directory), so upgrading mid-resubmit stays safe. The error message and stale-lock guidance are unchanged.Evidence (Ubuntu 26.04, two-way races of the bare primitive):
mkdir0.8.0 (/usr/bin/mkdir)mkdir(/usr/bin/gnumkdir)set -o noclobber; : > lockA 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
test_held_lock_refuses_a_resubmit_even_when_mkdir_is_not_exclusive: amkdirstub on PATH never reports an existing directory; a held lock must still refuse the resubmit and queue nothing. Fails onmain(DID NOT RAISE), passes with this change.test_two_concurrent_resubmits_queue_one_jobunder coverage on 2 CPUs (closest local match to CI):main2/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 themlflow/telemetry extras ignored locally).pre-commit run --files nemo_gym/orchestration/executors/slurm.py tests/unit_tests/test_eval_resubmit.pypasses.Nemo_CICD_Testgreen (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