mirror of
https://github.com/coredns/coredns.git
synced 2026-08-20 23:08:28 -04:00
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:
6
plugin/cache/handler.go
vendored
6
plugin/cache/handler.go
vendored
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user