From 65b4b100a88f73ed548b7015d796cb74b675145c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 29 Jun 2022 14:44:26 -0700 Subject: [PATCH] de-couple caller context to avoid internal races (#15195) ``` fatal error: concurrent map iteration and map write fatal error: concurrent map iteration and map write goroutine 745335841 [running]: runtime.throw({0x273e67b?, 0x80?}) runtime/panic.go:992 +0x71 fp=0xc0390bc240 sp=0xc0390bc210 pc=0x438671 runtime.mapiternext(0x40d987?) runtime/map.go:871 +0x4eb fp=0xc0390bc2b0 sp=0xc0390bc240 pc=0x41002b runtime.mapiterinit(0x46bec7?, 0x4ef76c?, 0xc0017cc9c0?) runtime/map.go:861 +0x228 fp=0xc0390bc2d0 sp=0xc0390bc2b0 pc=0x40fae8 reflect.mapiterinit(0x1b5?, 0xc0?, 0x235bcc0?) ``` ``` github.com/minio/minio/internal/rest/client.go:151 +0x5f4 fp=0xc0390bd988 sp=0xc0390bd730 pc=0x153e434 ``` --- internal/rest/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/rest/client.go b/internal/rest/client.go index 9d264fc1b..9425bc41b 100644 --- a/internal/rest/client.go +++ b/internal/rest/client.go @@ -148,7 +148,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod atomic.AddUint64(&networkErrsCounter, 1) } if c.MarkOffline() { - logger.LogIf(ctx, fmt.Errorf("Marking %s temporary offline; caused by %w", c.url.String(), err)) + logger.LogIf(context.Background(), fmt.Errorf("Marking %s temporary offline; caused by %w", c.url.String(), err)) } } return nil, &NetworkError{err} @@ -171,7 +171,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod // fully it should make sure to respond with '412' // instead, see cmd/storage-rest-server.go for ideas. if c.HealthCheckFn != nil && resp.StatusCode == http.StatusPreconditionFailed { - logger.LogIf(ctx, fmt.Errorf("Marking %s temporary offline; caused by PreconditionFailed with disk ID mismatch", c.url.String())) + logger.LogIf(context.Background(), fmt.Errorf("Marking %s temporary offline; caused by PreconditionFailed with disk ID mismatch", c.url.String())) c.MarkOffline() } defer xhttp.DrainBody(resp.Body) @@ -183,7 +183,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod atomic.AddUint64(&networkErrsCounter, 1) } if c.MarkOffline() { - logger.LogIf(ctx, fmt.Errorf("Marking %s temporary offline; caused by %w", c.url.String(), err)) + logger.LogIf(context.Background(), fmt.Errorf("Marking %s temporary offline; caused by %w", c.url.String(), err)) } } return nil, err