Skip to content

fix: isolate storage mutation guards by exact resource - #258

Merged
Vonng merged 1 commit into
mainfrom
codex/lock-isolation-review
Oct 26, 2026
Merged

Vonng merged 1 commit into
mainfrom
codex/lock-isolation-review

Conversation

@Vonng

@Vonng Vonng commented Oct 26, 2026

Copy link
Copy Markdown
Member

A paused storage mutation can block unrelated objects, including objects on healthy drives, when their drive/path hashes select the same process-wide mutex slot. Replace those slots with exact (drive, path) locks, keeping entries alive for both holders and waiters and acquiring unique paths in a consistent order. Same-resource serialization and cancellation/late-commit behavior are preserved.

Validation:

  • Real RenameData / UpdateMetadata regression fails with the old helper and passes with this change.
  • Mutation/rollback/cancellation race tests passed three times; additional mixed-lifecycle race stress passed 1,152,000 lock operations.
  • Full ordinary suite passed (52 packages), make verifiers passed, and native plus Linux amd64 builds passed.

The registry adds allocation and synchronization cost (about 432 ns/op in the 8-worker independent lock microbenchmark); short local storage benchmarks showed no metadata-update regression. Idle entries are removed, while the Go map can retain peak capacity. Disk format, wire interfaces, configuration and dependencies are unchanged.

Replace process-wide hash-slot mutexes with reference-counted locks keyed
by drive and path. Retain entries before waiting, acquire unique paths in
order, and reclaim entries only after all holders and waiters finish.

Add real storage API regressions for unrelated colliding objects and drives,
plus coverage for cancellation, multi-path order and waiter lifetimes.

Signed-off-by: Feng Ruohang <rh@vonng.com>
@Vonng
Vonng merged commit a13efd5 into main Oct 26, 2026
8 checks passed
@Vonng Vonng added the bug Something isn't working label Oct 27, 2026
@Vonng Vonng added this to the 20261026 milestone Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant