From 4d35413f0c26101daaaf69f47c73b0d9131e612a Mon Sep 17 00:00:00 2001 From: Bartlomiej Plotka Date: Mon, 15 Jun 2020 22:21:33 +0100 Subject: [PATCH 1/2] Revert "Let forward requests run until timeout (#2679)" This reverts commit 92fa67d1b8616b87c0aeaf5f499292e319a13c09. --- pkg/receive/handler.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index 938ede956f..07acf15c64 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -517,17 +517,11 @@ func (h *Handler) replicate(ctx context.Context, tenant string, wreq *prompb.Wri } h.mtx.RUnlock() - var err error ctx, cancel := context.WithTimeout(ctx, h.options.ForwardTimeout) - defer func() { - // If there is no error, let forward requests optimistically run until timeout. - if err != nil { - cancel() - } - }() + defer cancel() quorum := h.writeQuorum() - err = h.fanoutForward(ctx, tenant, replicas, wreqs, quorum) + err := h.fanoutForward(ctx, tenant, replicas, wreqs, quorum) if countCause(err, isNotReady) >= quorum { return tsdb.ErrNotReady } From 4f822de60020ed5693cabb2b27aacfd23974d376 Mon Sep 17 00:00:00 2001 From: Bartlomiej Plotka Date: Tue, 16 Jun 2020 06:25:21 +0100 Subject: [PATCH 2/2] Minor style fixes. Signed-off-by: Bartlomiej Plotka --- pkg/receive/handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index 07acf15c64..0469aaef73 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -230,7 +230,7 @@ func (h *Handler) handleRequest(ctx context.Context, rep uint64, tenant string, replicated: rep != 0, } - // on-the-wire format is 1-indexed and in-code is 0-indexed so we decrement the value if it was already replicated. + // On-the-wire format is 1-indexed and in-code is 0-indexed so we decrement the value if it was already replicated. if r.replicated { r.n-- } @@ -450,7 +450,7 @@ func (h *Handler) fanoutForward(ctx context.Context, tenant string, replicas map close(ec) }() - // At the end, make sure to exhaust the channel, letting remaining unnecessary requests finish asnychronously. + // At the end, make sure to exhaust the channel, letting remaining unnecessary requests finish asynchronously. // This is needed if context is cancelled or if we reached success of fail quorum faster. defer func() { go func() {