From 6f78ffe33cf8f0d6534db5fe8acd663d790e9020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD=E5=BF=A0?= Date: Tue, 31 Aug 2021 16:14:17 +0800 Subject: [PATCH] [fix] distributor: fix goroutine leak (#4238) Signed-off-by: fuling --- pkg/distributor/distributor.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 98c43007fa..1ea4f56e90 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -300,6 +300,14 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log case <-tracker.done: return &logproto.PushResponse{}, validationErr case <-ctx.Done(): + go func() { + select { + case <-tracker.err: + return + case <-tracker.done: + return + } + }() return nil, ctx.Err() } }