-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 external sort #46052
colexec: fix external sort #46052
Conversation
In order for the problem of "losing" the data to actually happen there are a couple of preconditions:
I was able to reproduce the problem pretty quickly in tests with |
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.
I'm hitting this pretty easily in my #45892 PR so that's a good sign.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @asubiotto and @yuzefovich)
pkg/sql/colexec/external_sort.go, line 429 at r1 (raw file):
func (o *inputPartitioningOperator) reset() { if o.propagateReset {
Intuitively, I would expect deep resets to be the default, which it currently isn't. How would it look if we switch it around?
3f24140
to
860e7e8
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)
pkg/sql/colexec/external_sort.go, line 429 at r1 (raw file):
Previously, asubiotto (Alfonso Subiotto Marqués) wrote…
Intuitively, I would expect deep resets to be the default, which it currently isn't. How would it look if we switch it around?
Yeah, I agree this way is nicer, done.
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 @yuzefovich)
pkg/sql/colexec/external_sort.go, line 429 at r1 (raw file):
Previously, yuzefovich wrote…
Yeah, I agree this way is nicer, done.
Maybe rename to interceptReset
or something similar to avoid the double negative. i.e. if !interceptReset { reset operator tree}
860e7e8
to
1076a65
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)
pkg/sql/colexec/external_sort.go, line 429 at r1 (raw file):
Previously, asubiotto (Alfonso Subiotto Marqués) wrote…
Maybe rename to
interceptReset
or something similar to avoid the double negative. i.e.if !interceptReset { reset operator tree}
Done.
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 @yuzefovich)
pkg/sql/colexec/external_sort.go, line 366 at r3 (raw file):
// interceptReset determines whether the reset method will be called on // the input to this operator when the latter is being reset. This field is // managed by externalSorter.
Sorry, I missed this. Add that the field is reset by the inputPartitioningOperator
after a reset
.
Release justification: bug fixes and low-risk updates to new functionality. This commit fixes the resetting behavior of inputPartitioningOperator (used by the external sort to figure out when to start a new partition when spilling the input) that was recently broken when we added the fallback from the external hash joiner to external sort plus merge joiner. The complication here is that we need two kinds of behaviors when inputPartitioningOperator is being reset: 1. ("shallow" reset) we need to clear the memory account because the external sorter is moving on spilling the data into a new partition. However, we *cannot* propagate the reset further up because it might delete the data that the external sorter has not yet spilled. This behavior is needed in externalSorter when resetting the in-memory sorter when spilling the next "chunk" of data into the new partition. 2. ("deep" reset) we need to do the full reset of the whole chain of operators. This behavior is needed when the whole external sorter is being reset. Release note: None.
1076a65
to
0cc326d
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)
pkg/sql/colexec/external_sort.go, line 366 at r3 (raw file):
Previously, asubiotto (Alfonso Subiotto Marqués) wrote…
Sorry, I missed this. Add that the field is reset by the
inputPartitioningOperator
after areset
.
Done.
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! 1 of 0 LGTMs obtained (waiting on @asubiotto)
TFTR! bors r+ |
Build succeeded |
Release justification: bug fixes and low-risk updates to new
functionality.
This commit fixes the resetting behavior of inputPartitioningOperator
(used by the external sort to figure out when to start a new partition
when spilling the input) that was recently broken when we added the
fallback from the external hash joiner to external sort plus merge
joiner. The complication here is that we need two kinds of behaviors
when inputPartitioningOperator is being reset:
external sorter is moving on spilling the data into a new partition.
However, we cannot propagate the reset further up because it might
delete the data that the external sorter has not yet spilled. This
behavior is needed in externalSorter when resetting the in-memory sorter
when spilling the next "chunk" of data into the new partition.
operators. This behavior is needed when the whole external sorter is
being reset.
Fixes: #46033.
Fixes: #46061.
Release note: None.