Skip to content

fix: prevent concurrent task metadata corruption - #64

Merged
TSLsun merged 4 commits into
mainfrom
fix/task-metadata-race
Oct 30, 2026
Merged

TSLsun merged 4 commits into
mainfrom
fix/task-metadata-race

Conversation

@TSLsun

@TSLsun TSLsun commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Concurrent fm_set and fm_del calls shared TASK.md.tmp and performed unlocked read-modify-write operations, causing lost updates and missing-temp rename errors. Serialize each complete mutation with a Bash 3.2-compatible per-file lock, write through a unique adjacent temporary file, and preserve the original on failures.

Cleanup traps release locks and temporary files on failure and termination while preserving caller traps and file permissions. Lock acquisition is bounded; SIGKILL or a machine crash can leave a stale lock requiring manual cleanup after confirming no writer owns it.

Require both success and a verbose creation receipt from mkdir to handle Ubuntu 26.04's uutils race bug, where losing racers can incorrectly exit successfully. The concurrent regression reproduced this on Ubuntu 26.04, and a deterministic false-success regression protects the workaround.

Validation:

  • make check: lint and all 218 tests passed locally on macOS after pulling the latest main.
  • Seven metadata regressions cover 40 concurrent setter/deleter pairs, false-success lock acquisition, failure preservation, termination cleanup, contention, permissions, and caller traps.
  • All seven metadata tests also passed under Bash 3.2 and in Ubuntu 26.04 with eight parallel Bats jobs.
  • The initial regressions failed against the original implementation; git diff --check passed.

@TSLsun
TSLsun merged commit 96e2790 into main Oct 30, 2026
3 of 4 checks passed
@TSLsun
TSLsun deleted the fix/task-metadata-race branch October 30, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant