-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colexec: fix simpleProjectOp in some cases #45690
Conversation
6b4f32e
to
9600537
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)
pkg/sql/colexec/simple_project.go, line 110 at r1 (raw file):
// We pass in a copy of d.projection just to be safe. projBatch = newProjectionBatch(append([]uint32{}, d.projection...)) d.batches[batch] = projBatch
Do we have any guarantee that this map will grow only as large as there are nodes in the cluster? I'm worried about potential cases in which batch pointers always differ. Don't know when that would be the case though, since when we buffer batches, we usually copy to an output batch (at least in the sorter), right?
6547b7d
to
f4b73b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @asubiotto and @jordanlewis)
pkg/sql/colexec/simple_project.go, line 110 at r1 (raw file):
Previously, asubiotto (Alfonso Subiotto Marqués) wrote…
Do we have any guarantee that this map will grow only as large as there are nodes in the cluster? I'm worried about potential cases in which batch pointers always differ. Don't know when that would be the case though, since when we buffer batches, we usually copy to an output batch (at least in the sorter), right?
We don't have such guarantee. In theory, if an upstream operator instantiates a new batch on its every Next
call, this map can grow unboundedly. In practice though I also can't think of an operator that behaves this way.
Maybe another way to fix this could be during planning. We have full knowledge of both arms of the unordered synchronizer. Could we plan the simple project operators before feeding into the unordered synchronizer? Or does that make no sense. |
Possibly my explanation and the example are somewhat misleading. I believe the root of the problem is with |
f4b73b6
to
a35d5d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, 2 of 2 files at r2.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)
pkg/sql/colexec/simple_project.go, line 102 at r2 (raw file):
projection: projection, batches: make(map[coldata.Batch]*projectingBatch), numBatchesLoggingThreshold: 4,
I would maybe make this larger, say 128. I think 4 could be expected.
`simpleProjectOp` doesn't work well together with unordered synchronizers (and possibly other components that can return `coldata.Batch`es that point to different regions of memory). The problem is that `simpleProjectOp` adds a `projectingBatch` wrapper on top its input batch, but if "different internally" batches come in, the wrapper is not updated/reset. Now this is fixed by tracking different input batches and having a separate `projectingBatch` for them. Release note (bug fix): Previously, an internal error could occur in CockroachDB when executing queries via the vectorized engine in queries that contained unordered synchronizers, and now this has been fixed.
a35d5d7
to
57eb4f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
bors r+
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @asubiotto and @jordanlewis)
pkg/sql/colexec/simple_project.go, line 102 at r2 (raw file):
Previously, asubiotto (Alfonso Subiotto Marqués) wrote…
I would maybe make this larger, say 128. I think 4 could be expected.
Done.
Build failed (retrying...) |
Build failed (retrying...) |
bors r+ |
Build succeeded |
simpleProjectOp
doesn't work well together with unorderedsynchronizers (and possibly other components that can return
coldata.Batch
es that point to different regions of memory). Theproblem is that
simpleProjectOp
adds aprojectingBatch
wrapper ontop its input batch, but if "different internally" batches come in, the
wrapper is not updated/reset. Now this is fixed by tracking different
input batches and having a separate
projectingBatch
for them.Fixes: #45686.
Release note (bug fix): Previously, an internal error could occur in
CockroachDB when executing queries via the vectorized engine in queries
that contained unordered synchronizers, and now this has been fixed.