Add cross-session file locking + concurrent build tests#11
Merged
Conversation
Move target and database lock files from per-session temp directories (/tmp/redo-<user>/<session>/) to a global location (/tmp/redo-<uid>-locks/). Previously, each top-level redo invocation used its own REDO_SESSION-scoped lock directory, meaning two separate `redo` commands could not coordinate locks on shared targets. This caused potential races when building the same target tree from multiple terminals or scripts. Now lock files are UID-namespaced in /tmp for auto-cleanup on reboot, and shared across all redo sessions for the same user. The flock() mechanism is unchanged, only the directory location moves.
Five tests exercising cross-session concurrency: 1. Same target from two processes simultaneously 2. Overlapping dependency chains with shared deep dep 3. Stress test: 4 processes building same target 4. Different targets with shared slow dependency 5. Rapid-fire rebuild after .do file invalidation Tests use sleep delays to create race windows and verify output correctness after concurrent builds complete.
dinkelk
force-pushed
the
feature/cross-session-locking-v2
branch
from
March 11, 2026 20:32
f487d38 to
860f1f6
Compare
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.
Two commits:
1. Cross-session file locking
Moves target and database lock files from per-session temp directories (
/tmp/redo-<user>/<session>/) to a global location (/tmp/redo-<uid>-locks/).Before: Each top-level
redoinvocation used its ownREDO_SESSION-scoped lock directory. Two separateredocommands could not coordinate locks on shared targets — they'd both build the same target simultaneously.After: Lock files are UID-namespaced in
/tmp(auto-cleanup on reboot) and shared across all redo sessions for the same user. Theflock()mechanism is unchanged — only the directory location moves.2. Concurrent build tests (
test/410-concurrent/)5 tests exercising cross-session concurrency:
Why
The existing locking only worked for intra-session parallelism (
-jflag). When two separateredoprocesses built overlapping targets, they couldn't see each other's locks. This is a real scenario in CI pipelines, multi-terminal development, and script-driven builds.