Skip to content

fix(diskcache): make Close terminal#196

Merged
coanor merged 1 commit into
mainfrom
fix/diskcache-close-lifecycle
Jul 16, 2026
Merged

fix(diskcache): make Close terminal#196
coanor merged 1 commit into
mainfrom
fix/diskcache-close-lifecycle

Conversation

@leecha

@leecha leecha commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

Operations arriving after Close could reopen the WAL because a missing writer was treated as a recoverable rotation state. This could allow stale cache instances to write after ownership changed and leave file descriptors open.

Fix

  • Add a terminal closed state and ErrClosed.
  • Make Close wait for in-flight operations.
  • Close all resources before releasing the directory lock.
  • Keep the lock file to ensure safe ownership handoff.
  • Preserve writer recovery after rotation failures.
  • Add lifecycle, ownership, resource cleanup, and race regression tests.

Validation

  • go test ./diskcache
  • Targeted race tests
  • Windows cross-compilation

@leecha
leecha requested a review from coanor July 16, 2026 06:13
@coanor
coanor merged commit 27c2650 into main Jul 16, 2026
2 checks passed
@coanor
coanor deleted the fix/diskcache-close-lifecycle branch July 16, 2026 06:36
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.

2 participants