-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
colexec: refactor how we track closers
This commit introduces `colexecargs.CloserRegistry` which is now responsible for tracking all `colexecop.Closer`s we create during the vectorized planning. Previously, we would accumulate them in `NewColOperatorResult.ToClose` slice to be appended to the `closers` slice in the vectorized flow. However, the following commit will make creation of some closers lazy, meaning that the captured `result.ToClose` slice might have incomplete information, and this commit goes around that issue. This commit should be a no-op change as of right now. Release note: None
- Loading branch information
1 parent
bc408e5
commit 1669fad
Showing
16 changed files
with
219 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the CockroachDB Software License | ||
// included in the /LICENSE file. | ||
|
||
package colexecargs | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror" | ||
"github.com/cockroachdb/cockroach/pkg/sql/colexecop" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
) | ||
|
||
type CloserRegistry struct { | ||
toClose colexecop.Closers | ||
} | ||
|
||
func (r *CloserRegistry) NumClosers() int { | ||
return len(r.toClose) | ||
} | ||
|
||
func (r *CloserRegistry) AddCloser(closer colexecop.Closer) { | ||
r.toClose = append(r.toClose, closer) | ||
} | ||
|
||
func (r *CloserRegistry) AddClosers(closers colexecop.Closers) { | ||
r.toClose = append(r.toClose, closers...) | ||
} | ||
|
||
func (r *CloserRegistry) Close(ctx context.Context) { | ||
if err := colexecerror.CatchVectorizedRuntimeError(func() { | ||
for _, closer := range r.toClose { | ||
if err := closer.Close(ctx); err != nil && log.V(1) { | ||
log.Infof(ctx, "error closing Closer: %v", err) | ||
} | ||
} | ||
}); err != nil && log.V(1) { | ||
log.Infof(ctx, "runtime error closing the closers: %v", err) | ||
} | ||
} | ||
|
||
func (r *CloserRegistry) Reset() { | ||
for i := range r.toClose { | ||
r.toClose[i] = nil | ||
} | ||
r.toClose = r.toClose[:0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.