-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sstable: fix twoLevelIterator SeekGE optimization
The current TrySeekUsingNext optimization had a bug where a first SeekGE could set exhaustedBounds=+1, and the next monotonic twoLevelIterator.SeekGE (without changing bounds) would set exhaustedBounds back to 0, call singleLevelIterator.SeekGE which would immediately return because of i.data.isDataInvalidated() (and TrySeekUsingNext), which would cause the twoLevelIterator to step the top-level index iterator. This woud break a subsequent optimization when the bounds were monotonically advanced, since the top-level index iterator had been advanced too far. See #2036 (comment) for an example of the bug. Given that both singleLevelIterator and twoLevelIterator use the exhaustedBounds value from the previous SeekGE call for the TrySeekUsingNext optimization, the twoLevelIterator should be selective on when it resets exhaustedBounds to 0. The logic behind when this can be done is not complex, so should be maintainable. This bug should only occur when using block property filters with the monotonic bound optimization: the second SeekGE in the above, which moves the top-level index too far forward would not happen if the singleLevelIterator was actually loading data blocks, since the singleLevelIterator would do some work and set exhaustedBound back to +1. The PR also constrains this TrySeekUsingNext fast path to the case where i.err == nil. This was an oversight, though very unlikely to happen in practice. There are todos added to make further changes after we backport this change: - The twoLevelIterator.SeekPrefixGE code does not currently utilize TrySeekUsingNext. There is no reason to hold back on this optimization. - The cases where the twoLevelIterator is already exhausted are not optimized. We will wastefully reseek the top level index. Fixes #2036
- Loading branch information
1 parent
f34af25
commit a456811
Showing
17 changed files
with
407 additions
and
117 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.