Skip to content

Commit

Permalink
colexec: protect columnarizer when closing not started input
Browse files Browse the repository at this point in the history
This commit makes sure that the columnarizer calls `InternalClose` only
if it has been initialized. Previously, if `Columnarizer.Init` wasn't
performed (most likely due to a panic in `Init` of another operator),
the columnarizer's input would not be started, so when `InternalClose`
called `input.ConsumerClosed`, that could lead to a nil pointer panic
since `input.Ctx` would be `nil` if the input tried to do some logging
(some processors do that). We now protect against this by
short-circuiting `InternalClose` call altogether, similar to what we do
in `Columnarizer.DrainMeta`. This makes it so that the columnarizer
satisfies `Closer.Close` contract properly.

Release note: None
  • Loading branch information
yuzefovich committed Nov 7, 2022
1 parent d9cc084 commit 4ab5ce9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/sql/colexec/columnarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ func (c *Columnarizer) Close(context.Context) error {
return nil
}
c.helper.Release()
if c.Ctx == nil {
// The columnarizer wasn't initialized, so the wrapped processors might
// not have been started leaving them in a state unsafe for the
// InternalClose, so we skip that. Mostly likely this happened because a
// panic was encountered in Init.
return nil
}
c.InternalClose()
return nil
}
Expand Down

0 comments on commit 4ab5ce9

Please sign in to comment.