From 9f529f9ef2d245a522fede5ed81783ffa65c58ec Mon Sep 17 00:00:00 2001
From: Goutham Veeramachaneni <gouthamve@gmail.com>
Date: Wed, 8 May 2019 21:16:16 +0530
Subject: [PATCH] Fix timeout to be in the right place.

Previously we also included encoding times and those shouldn't be
included.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
---
 pkg/ingester/flush.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pkg/ingester/flush.go b/pkg/ingester/flush.go
index 7bdeae54..5cc80cb3 100644
--- a/pkg/ingester/flush.go
+++ b/pkg/ingester/flush.go
@@ -169,8 +169,6 @@ func (i *Ingester) flushUserSeries(userID string, fp model.Fingerprint, immediat
 	}
 
 	ctx := user.InjectOrgID(context.Background(), userID)
-	ctx, cancel := context.WithTimeout(ctx, i.cfg.FlushOpTimeout)
-	defer cancel()
 	err := i.flushChunks(ctx, fp, labels, chunks)
 	if err != nil {
 		return err
@@ -264,6 +262,9 @@ func (i *Ingester) flushChunks(ctx context.Context, fp model.Fingerprint, labelP
 		wireChunks = append(wireChunks, c)
 	}
 
+	ctx, cancel := context.WithTimeout(ctx, i.cfg.FlushOpTimeout)
+	defer cancel()
+
 	if err := i.store.Put(ctx, wireChunks); err != nil {
 		return err
 	}
-- 
GitLab