From 2cf506be40405d6cecb13be5260acae6515d4f77 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Tue, 4 Jun 2024 08:19:04 -0500 Subject: [PATCH] core/services/pipeline: hide deadline from monitor --- core/services/pipeline/runner.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/services/pipeline/runner.go b/core/services/pipeline/runner.go index 40444ffd3e0..1e2f6509a56 100644 --- a/core/services/pipeline/runner.go +++ b/core/services/pipeline/runner.go @@ -236,10 +236,16 @@ func init() { // results, even after context cancellation. func overtimeContext(ctx context.Context) (context.Context, context.CancelFunc) { if d, ok := ctx.Deadline(); ok { - // extend deadline - return context.WithDeadline(context.WithoutCancel(ctx), d.Add(overtime)) - } - // remove cancellation + // We do not use context.WithDeadline/Timeout in order to prevent the monitor hook from logging noisily, since + // we expect and want these operations to use most of their allotted time. + // TODO replace with custom thresholds: https://smartcontract-it.atlassian.net/browse/BCF-3252 + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(context.WithoutCancel(ctx)) + t := time.AfterFunc(time.Until(d.Add(overtime)), cancel) + stop := context.AfterFunc(ctx, func() { t.Stop() }) + return ctx, func() { cancel(); stop() } + } + // do not propagate cancellation in any case return context.WithoutCancel(ctx), func() {} }