-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Fix a bug in TOP #121552
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
Merged
Merged
ESQL: Fix a bug in TOP #121552
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3b784b8
ESQL: Fix a bug in TOP
nik9000 cab7aad
Update docs/changelog/121552.yaml
nik9000 2ca45b7
allocate whole buckets at a time
nik9000 5dc546f
Merge remote-tracking branch 'nik9000/top_bug' into top_bug
nik9000 d7248cd
Flip others
nik9000 fce864b
[CI] Auto commit changes from spotless
5b621ba
Merge branch 'main' into top_bug
nik9000 e332b82
Merge branch 'main' into top_bug
nik9000 e3e8dc3
Flip impl
nik9000 a5bd96a
Merge branch 'main' into top_bug
nik9000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| pr: 121552 | ||
| summary: Fix a bug in TOP | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
It's not obvious to me how this guards against oversizing of
other.values. Without being too familiar with this code, couldn't it happen in theory that the oversizing is by more than a whole bucketsize, and thenotherEndmay still be< other.values.size()while the value may still not have been collected?Would it make sense to, alternatively, check if the value at the
otherRootIndexis not null? Per the invariant check, if any value was ever collected into the bucket, then the root value must not be null, right? So the condition would beotherRootIndex >= other.values.size() || other.values.get(otherRootIndex) == null.If I'm reading this correctly, the present code would still trigger a failed assertion at
other.checkInvariant(otherBucket)if theother.valuesarray was oversized bybucketSizeor more, and no value was ever collected into that bucket.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.
We always fill the newly allocated gather offsets with the appropriate encoded value. We wanted to make sure we didn't have to do that test.
I suppose ideally we would size in units of whole buckets. I think I could do that actually. That'd be better. No reason to have this half grown array.
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.
Wouldn't resizing in units of whole buckets still have the problem that you may have sized the array such that there's enough room for one more bucket, but the bucket itself is not yet in use/empty? Or do we only ever resize when we immediately put a value into the bucket AND never go over the size of a single bucket when resizing? If the latter is true, then I think we need to put a comment here as it's non-obvious IMHO.
Put differently, I understand that the current condition
otherRootIndex >= other.values.size()is insufficient to determine all cases when the other bucket is actually empty. And it'd be great if the condition that we end up using is somewhat reasonably easy to prove correct; as when it's not correct, we get AssertErrors, which cause whole test suites to fail and be muted.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've pushed a patch that does that. It's a little bigger but feels nicer.