Azure / Azure/unbounded

Gantry: 11 - negcache callback lock hygiene

Open Beginner friendly
#287 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.