Repository navigation
test(runtime): prove a lease closed in a forked child keeps the parent's locks - #1459
Merged
Merged
Conversation
…t's locks The fork test patched os.getpid in one process and then re-acquired the lease, which succeeds whether or not close() unlocks in a non-owner process. After a real fork the parent shares the child's open file descriptions, so a child that unlocked them would release the parent's lease. Hold duplicates of the lease descriptors, close as a non-owner and probe both flock locks.
doublewhy
marked this pull request as ready for review
October 9, 2026 13:45
This was referenced Oct 9, 2026
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
Part of #1344, the fixture-provenance audit.
RuntimeOwnerLease.close()(control_plane_store_lease.py:217-231) releases itsflocklocks only in the process that acquired the lease, and_release_store_directory_guard(:113-120) does the same for the store-directory lock. The guards matter because afterfork()parent and child share open file descriptions: a child that unlocked its inherited descriptors would release the parent's single-owner lease on the control-plane store.Neither existing fork test can see these guards.
test_runtime_owner_lease_rejects_and_closes_in_a_different_process_identitypatchesos.getpidand re-acquires after closing the only descriptor, which drops the lock either way;test_inherited_runtime_owner_fails_closed_after_forknever closes the lease in the child. Both still pass with either guard removed, and with both removed.This PR adds a test that models the parent's surviving descriptors with
os.dup()(same open file description, as afterfork()), closes the lease as a non-owner, and probes both locks. No production code changes.Requirement UIDs
Related Issues
Closes #1558
ADR Impact
Changes
test_runtime_owner_lease_closed_in_a_forked_child_keeps_the_parent_locksintest_issue_1092_control_plane_crash_consistency.py. It duplicates the lease's lock-file and store-directory descriptors, closes the lease withos.getpidpatched to a different process, asserts that a fresh descriptor can take neither lock while the duplicates are open, and that the lease can be re-acquired after they close. Skipped on Windows, where the directory guard does not exist and the lock is not aflock. A helper,_runtime_owner_lock_is_held, probes a path with the production_lock_runtime_owner.Done-when matrix (issue #1558, verbatim):
dev.test_issue_1092_control_plane_crash_consistency.py:test_runtime_owner_lease_closed_in_a_forked_child_keeps_the_parent_locksclose()unlocks in any process) and MB (_release_store_directory_guardunlocks in any process), each reverted afterwards: the new test fails under each, and the two existing fork tests passcanonical / test-sharddocs/research/fixture-provenance/index.mdand its row ininventory.mdrecord the fix.gh pr view 1461shows OPENTest Plan
uv run --project implementations/python --frozen --all-extras python -m pytest implementations/python/tests/test_issue_1092_control_plane_crash_consistency.py: 108 passed, 2 skipped, 3 deselected. With-m integration: 3 passed, 110 deselected. With MA, MB, or both patched in from a pytest plugin and integration tests selected (-m "not fuzz and not docker"), only the new test fails.A real-fork check (standalone script, macOS, CPython 3.14.4 and 3.12.13, package code at e648556, unchanged from
dev) confirmed the hazard: the parent acquires a lease and forks, the child closes its inherited lease, and a separate process then tries bothflocks andRuntimeOwnerLease.acquire(). Both interpreters printed the same results:flockflockacquire()_acquire_store_directory_guard)_acquire_store_directory_guard)_claim_runtime_owner_file)The new test uses
os.dup()rather thanos.fork(), so it runs in the default (non-integration) lane without forking.nox -s verify-fast-feedback -- --base-rev origin/devpassed; ruff format and check are clean fromimplementations/python.CI on head
e6485562(dev base): CI run 37918028762 and Docs 37918027796 passed; 28 checks passed and onlydeploywas skipped (checked 2026-10-13). No research capture is recorded because no evidence-bound source changes.Ground Control Checks
Traceability
implementations/python/tests/test_issue_1092_control_plane_crash_consistency.pyimplementations/python/packages/raes_runtime/control_plane_store_lease.py(RuntimeOwnerLease.close,_release_store_directory_guard)docs/requirements/API-404/requirement.md:280; this test module as TESTS,:308); SEM-225 (:52) and RUN-320 (:101) also trace the test module. No traceability lines change.Checklist
CHANGELOG.mdfrom it)