gen-index: serialize concurrent runs, unique tmp files #5

Open
Breadway wants to merge 0 commits from fix/gen-index-concurrent-publish into main
Owner

Concurrent dev-release runs (breadbar + breadbox this round) both write ${OUT}.tmp in the shared DL dir; the loser's mv fails No such file or directory and set -e reddens the publish job even though the index was written fine. This is why breadbar run 126 (the shell-theme publish) looked failed.

flock a per-track lock + mktemp -u the tmp paths. Verified 2 concurrent runs both exit 0 with one consistent index.json.

Concurrent dev-release runs (breadbar + breadbox this round) both write `${OUT}.tmp` in the shared DL dir; the loser's `mv` fails `No such file or directory` and `set -e` reddens the publish job even though the index was written fine. This is why breadbar run 126 (the shell-theme publish) looked failed. flock a per-track lock + `mktemp -u` the tmp paths. Verified 2 concurrent runs both exit 0 with one consistent index.json.
Breadway added 1 commit 2026-09-01 14:30:28 +08:00
Every repo's dev-release / beta-release workflow runs this script after its
build. Two merges landing in the same round (breadbar + breadbox this week)
run it concurrently on the one self-hosted runner, both writing
`${OUT}.tmp` in the shared output dir. The second `mv "${OUT}.tmp" "${OUT}"`
then fails "No such file or directory" — the first run already consumed it —
and `set -e` turns that into a red publish job, even though the index was
written correctly by the other run.

That's the whole reason breadbar's dev-release (run 126, the shell-theme
publish) showed red and the theme-capable binary looked unpublished.

- flock a per-track lock for the whole run, so the two invocations serialize
  and the later one also sees the earlier's fresh `latest` symlink.
- mktemp -u the index.json / .minisig temp paths so even an unlocked caller
  (INDEX_LOCK override, older workflow) can't collide.

Verified: two concurrent runs against a fake DL tree both exit 0 with one
consistent index.json and no leftover .tmp.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/gen-index-concurrent-publish:fix/gen-index-concurrent-publish
git checkout fix/gen-index-concurrent-publish

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff fix/gen-index-concurrent-publish
git checkout fix/gen-index-concurrent-publish
git rebase main
git checkout main
git merge --ff-only fix/gen-index-concurrent-publish
git checkout fix/gen-index-concurrent-publish
git rebase main
git checkout main
git merge --no-ff fix/gen-index-concurrent-publish
git checkout main
git merge --squash fix/gen-index-concurrent-publish
git checkout main
git merge --ff-only fix/gen-index-concurrent-publish
git checkout main
git merge fix/gen-index-concurrent-publish
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Breadway/bread-ecosystem#5
No description provided.