From 5194e340d9e42084b6d7f200fada7bc50563d515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duchesneau?= Date: Thu, 4 Apr 2024 14:12:36 -0400 Subject: [PATCH] fix context leak causing tier1 responses to slow down progressively --- docs/release-notes/change-log.md | 4 ++++ service/tier1.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/change-log.md b/docs/release-notes/change-log.md index a523425e7..3c570c1bf 100644 --- a/docs/release-notes/change-log.md +++ b/docs/release-notes/change-log.md @@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v1.5.2 + +* Fix a context leak causing tier1 responses to slow down progressively + ## v1.5.1 * Fix a panic on tier2 when not using any wasm extension. diff --git a/service/tier1.go b/service/tier1.go index 21d3d5d36..aacad969e 100644 --- a/service/tier1.go +++ b/service/tier1.go @@ -552,6 +552,7 @@ func tier1ResponseHandler(ctx context.Context, mut *sync.Mutex, logger *zap.Logg userMeta := auth.Meta() ip := auth.RealIP() meter := dmetering.GetBytesMeter(ctx) + ctx = context.WithValue(ctx, "event_emitter", dmetering.GetDefaultEmitter()) return func(respAny substreams.ResponseFromAnyTier) error { resp := respAny.(*pbsubstreamsrpc.Response) @@ -567,7 +568,6 @@ func tier1ResponseHandler(ctx context.Context, mut *sync.Mutex, logger *zap.Logg return connect.NewError(connect.CodeUnavailable, err) } - ctx = context.WithValue(ctx, "event_emitter", dmetering.GetDefaultEmitter()) sendMetering(ctx, meter, userID, apiKeyID, ip, userMeta, "sf.substreams.rpc.v2/Blocks", resp, logger) return nil }