Skip to content

Commit 3e5562e

Browse files
authored
Merge pull request #160038 from yuzefovich/blathers/backport-release-26.1-159946
release-26.1: rowexec: add cancel checking to inverted joiner
2 parents 7013276 + 88f4a5e commit 3e5562e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/sql/rowexec/inverted_joiner.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2828
"github.com/cockroachdb/cockroach/pkg/sql/span"
2929
"github.com/cockroachdb/cockroach/pkg/sql/types"
30+
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker"
3031
"github.com/cockroachdb/cockroach/pkg/util/log"
3132
"github.com/cockroachdb/cockroach/pkg/util/metamorphic"
3233
"github.com/cockroachdb/cockroach/pkg/util/mon"
@@ -67,6 +68,8 @@ type invertedJoiner struct {
6768
unlimitedMemMonitor *mon.BytesMonitor
6869
diskMonitor *mon.BytesMonitor
6970

71+
cancelChecker cancelchecker.CancelChecker
72+
7073
// prefixEqualityCols are the ordinals of the columns from the join input
7174
// that represent join values for the non-inverted prefix columns of
7275
// multi-column inverted indexes. The length is equal to the number of
@@ -414,6 +417,11 @@ func (ij *invertedJoiner) Next() (rowenc.EncDatumRow, *execinfrapb.ProducerMetad
414417
func (ij *invertedJoiner) readInput() (invertedJoinerState, *execinfrapb.ProducerMetadata) {
415418
// Read the next batch of input rows.
416419
for len(ij.inputRows) < ij.batchSize {
420+
if err := ij.cancelChecker.Check(); err != nil {
421+
ij.MoveToDraining(err)
422+
return ijStateUnknown, nil
423+
}
424+
417425
row, meta := ij.input.Next()
418426
if meta != nil {
419427
if meta.Err != nil {
@@ -742,6 +750,7 @@ func (ij *invertedJoiner) Start(ctx context.Context) {
742750
&ij.scanStatsListener, &ij.tenantConsumptionListener,
743751
)
744752
ij.input.Start(ctx)
753+
ij.cancelChecker.Reset(ctx, 16 /* checkInterval */)
745754
ij.runningState = ijReadingInput
746755
}
747756

0 commit comments

Comments
 (0)