mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-17 21:54:30 +01:00
Make gstack's shell locks hold when mkdir reports a race it lost (GST-2247) (#4262)
* Make gstack's shell locks hold when mkdir reports a race it lost (GST-2247) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Fix lock tests and fixtures for gstack_lock_take; trim setup-gbrain lock prose Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Ship the lock helper with every copied runtime and fixture that runs a lock The Claude Code wrapper's copied runtime now includes bin/gstack-lock.sh, and bin/gstack-render-claude.sh sources it beside itself, so gstack-config set works in a copied runtime and the render lock is taken by every caller. Test fixtures that copy single bin scripts now copy the helper too, and the mkdir lock guard is registered as a repo-wide docs reader. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Release a lock whose owner file could not be fully written gstack_lock_take created the owner file with a noclobber redirect and, when that redirect failed, treated an existing file as a competing holder. If the file was created but the write then failed (disk full, quota, ulimit -f), the helper found its own empty file, returned 1 and left a lock nobody held; freeze's state lock has no stale recovery, so it stayed busy until removed by hand. The helper now tells "opened but write failed" from "already held", removes its own file and directory, and returns 3. The inline copy in gstack-ff-update is updated byte for byte, and a new test under ulimit -f 0 fails on the old helper. Review-Finding: s11/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Describe the lease lock as gstack_lock_take's O_EXCL owner file Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
76fad3edd9
commit
bcece3fbcd
50 files changed
+621
-154
No files matched your search
@@ -556,6 +556,13 @@ describe('gstack-ff-update: self-contained, with twins pinned', () => {
|
||||
expect(ffSrc).toContain('[ "$(cat "$LOCK_DIR/pid" 2>/dev/null)" = "$MYPID" ] && rm -rf "$LOCK_DIR" 2>/dev/null');
|
||||
});
|
||||
|
||||
// Value: protects=the self-contained bin takes its lock exactly like every other gstack lock; fails_when=the inlined gstack_lock_take drifts from bin/gstack-lock.sh; why_new=the lock moved off mkdir's exit status (Ubuntu 26.04 uutils); seam=none; no_claim=the race itself, proven in test/gstack-lock-race.test.ts
|
||||
test('the inlined gstack_lock_take is byte-identical to bin/gstack-lock.sh', () => {
|
||||
const lockSrc = fs.readFileSync(path.join(path.dirname(FF), 'gstack-lock.sh'), 'utf8');
|
||||
expect(fn(ffSrc, 'gstack_lock_take')).toBeDefined();
|
||||
expect(fn(ffSrc, 'gstack_lock_take')).toBe(fn(lockSrc, 'gstack_lock_take'));
|
||||
});
|
||||
|
||||
test.skipIf(process.platform === 'win32')('ff_flatten flattens newlines and strips control characters and escape sequences', () => {
|
||||
const r = spawnSync('bash', ['-c', `eval "$(sed -n '/^ff_flatten() {/,/^}/p' "${FF}")"; ff_flatten "$(printf 'bad\\nstages=x \\033[31mred\\033[0m\\001end')" 200`], { encoding: 'utf8', timeout: 30_000 });
|
||||
expect(r.stdout).toBe('bad stages=x redend');
|
||||
|
||||
Reference in new issue
Block a user