From 355ff7200da62d53ba560399d868f78ebac5b5ba Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Fri, 26 Aug 2022 19:48:19 +0000 Subject: [PATCH] rowexec: close all ValueGenerators in the project set processor Previously, we forgot to close the value generators when a new input row is read by the project set processor which could lead to leaking of the resources. This is now fixed. Most of the value generators don't need to release any resources, a few need to close their memory account (previously this would result in a sentry report, but no actual leak would occur in production builds), the only concerning one is `crdb_internal.payloads_for_trace` where we would not close the `InternalRows` iterator. But that seems like an internal debugging tool, so most likely the users weren't impacted. Release justification: bug fix. Release note: None (It seems like in most cases the users would not see the impact.) --- pkg/sql/rowexec/project_set.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/sql/rowexec/project_set.go b/pkg/sql/rowexec/project_set.go index 5f7a70273fd0..ca37d0ebd5cd 100644 --- a/pkg/sql/rowexec/project_set.go +++ b/pkg/sql/rowexec/project_set.go @@ -144,6 +144,13 @@ func (ps *projectSetProcessor) nextInputRow() ( if fn := ps.funcs[i]; fn != nil { // A set-generating function. Prepare its ValueGenerator. + // First, make sure to close its ValueGenerator from the previous + // input row (if it exists). + if ps.gens[i] != nil { + ps.gens[i].Close(ps.Ctx) + ps.gens[i] = nil + } + // Set ExprHelper.row so that we can use it as an IndexedVarContainer. ps.exprHelpers[i].Row = row