plugin/cache: Fix cache stale verification metadata race (#8366)

* plugin/cache: Fix cache stale verification metadata race

This PR fixes cache stale verification metadata race
which isolate background stale-refresh metadata from
the foreground request to prevent concurrent map writes and process crashes

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Address review comment

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2026-07-30 01:25:50 -07:00
committed by GitHub
parent 068d68888a
commit 36515d9dce
2 changed files with 102 additions and 1 deletions

View File

@@ -142,8 +142,12 @@ func (c *Cache) verifyWithTimeout(ctx context.Context, state request.Request, w
err error
}
done := make(chan result, 1)
refreshCtx := metadata.ContextWithMetadata(ctx)
for label, valueFunc := range metadata.ValueFuncs(ctx) {
metadata.SetValueFunc(refreshCtx, label, valueFunc)
}
go func() {
rc, re := c.doRefresh(ctx, state, cw)
rc, re := c.doRefresh(refreshCtx, state, cw)
done <- result{rc, re}
}()
timer := time.NewTimer(c.verifyStaleTimeout)