Skip to content

Commit c0b6be2

Browse files
kakkoyunthisisobate
authored andcommitted
Let forward requests run until timeout (thanos-io#2679)
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent a65286d commit c0b6be2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/receive/handler.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,17 @@ func (h *Handler) replicate(ctx context.Context, tenant string, wreq *prompb.Wri
517517
}
518518
h.mtx.RUnlock()
519519

520+
var err error
520521
ctx, cancel := context.WithTimeout(ctx, h.options.ForwardTimeout)
521-
defer cancel()
522+
defer func() {
523+
// If there is no error, let forward requests optimistically run until timeout.
524+
if err != nil {
525+
cancel()
526+
}
527+
}()
522528

523529
quorum := h.writeQuorum()
524-
err := h.fanoutForward(ctx, tenant, replicas, wreqs, quorum)
530+
err = h.fanoutForward(ctx, tenant, replicas, wreqs, quorum)
525531
if countCause(err, isNotReady) >= quorum {
526532
return tsdb.ErrNotReady
527533
}

0 commit comments

Comments
 (0)