Skip to content
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 coalescing logic in the spilling queue #59057

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

yuzefovich
Copy link
Member

In a recently merged change to the spilling queue we introduced a bug in
the coalescing logic - we incorrectly computed the index of the "tail"
batch in case when it is the last one in the in-memory buffer. This
could lead to multiple problems (modification of the filled-up batch, of
the already dequeued batch, etc). This is now fixed.

Additionally, this commit switches to using Copy instead of Append
in that coalescing logic (since we know that there is enough capacity
for all of the tuples we're appending) and sets the item to nil when
it was dequeued.

Addresses: #47652.
Fixes: #58913.
Fixes: #58915.
Fixes: #58934.
Fixes: #58935.
Fixes: #58936.
Fixes: #58956.

Release note: None (no stable release with this bug)

In a recently merged change to the spilling queue we introduced a bug in
the coalescing logic - we incorrectly computed the index of the "tail"
batch in case when it is the last one in the in-memory buffer. This
could lead to multiple problems (modification of the filled-up batch, of
the already dequeued batch, etc). This is now fixed.

Additionally, this commit switches to using `Copy` instead of `Append`
in that coalescing logic (since we know that there is enough capacity
for all of the tuples we're appending) and sets the item to `nil` when
it was dequeued.

Release note: None (no stable release with this bug)
@yuzefovich yuzefovich requested review from asubiotto and a team January 15, 2021 18:05
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/sql/colexec/spilling_queue.go, line 245 at r1 (raw file):

		tailBatchIdx := q.curTailIdx - 1
		if tailBatchIdx < 0 {
			tailBatchIdx = len(q.items) - 1

Added a comment about adding a unit test in the other PR.

Copy link
Contributor

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: In the interest of making nightlies pass again, but please follow up with another PR with a unit test.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)

@yuzefovich
Copy link
Member Author

Actually, I was wrong - the simple unit test I had in mind doesn't trigger the bug since in order for it to surface a careful coordination of enqueues and dequeues is required, so I'll go ahead and merge as is and will add a test in a follow-up.

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 15, 2021

Build succeeded:

@craig craig bot merged commit fbf48db into cockroachdb:master Jan 15, 2021
@yuzefovich yuzefovich deleted the fix-spilling-queue branch January 15, 2021 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants