Gantry: 11 - negcache callback lock hygiene
- Dominant language
- Go
- Stars
- 28
- Forks
- 11
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 55
Description
## Scope
Move negcache metric callbacks outside the mutex.
## Problem
negcache metric callbacks are invoked while holding `c.mu`. Current callbacks are safe, but future callbacks that re-enter the cache can deadlock.
Evidence:
- `internal/gantry/negcache/negcache.go:117-122`
## Changes
- Snapshot callback data under lock, unlock, then invoke `OnEnter`, `OnHit`, and `OnSize`.
## Tests
- A negcache callback that calls back into `Len()` does not deadlock.
Contributor guide
Research direction
Start in internal/gantry/negcache/negcache.go at lines 117-122 and trace the negcache metric callbacks. Verify that callback data is snapshotted while c.mu is held, then that OnEnter, OnHit, and OnSize run after unlocking. Add or run a test where a callback calls Len() and confirm it does not deadlock.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100