Repository navigation
fix: read the lock age with GNU stat first so Linux appends do not die - #2
Merged
Merged
Conversation
The stale-lock sweep in ledger-append.sh ran `stat -f %m || stat -c %Y`. On Linux, `stat -f` is filesystem status: it exits 0 and prints text, so the age arithmetic failed under `set -u` and the writer exited before it appended. Under contention, entries were lost (17 of 20 in an Ubuntu container), and a stale lock blocked every append. Run `stat -c %Y` first. BSD stat rejects `-c`, so macOS falls through to `stat -f %m`. Ignore any value that is not a number. verify.sh gains a check with a lock dir dated 2020. It fails on Linux with the old script and passes with this one.
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.
Problem
CI on
mainhas failed since 2026-10-06 on theledger-append.shconcurrency check. The log showsline 88: File: unbound variable.Cause
The stale-lock sweep ran
stat -f %m "$LOCK_DIR" || stat -c %Y "$LOCK_DIR". On Linux,stat -fmeans filesystem status: it exits 0 and prints text. The text went into the age arithmetic, which failed underset -u, and the writer exited before it appended. macOS was not affected.On Linux this meant:
What changed
scripts/ledger-append.sh: runsstat -c %Yfirst. BSD stat rejects-c, so macOS falls through tostat -f %m. A value that is not a number is ignored.verify.sh: a new check leaves a lock dir dated 2020. It expects the sweep to remove it at once and the entry to land with no timeout marker.Verification
verify.shpasses on macOS and in Ubuntu 24.04 with git installed.