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

sstable: don't skipBackward past empty blocks with hideObsolete #3785

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion sstable/reader_iter_single_lvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,15 @@ func (i *singleLevelIterator) skipBackward() *base.InternalKV {
}
kv := i.data.Last()
if kv == nil {
return nil
// The block iter could have hid some obsolete points, so it isn't
// safe to assume that there are no keys if we keep skipping backwards.
// Check the previous block, but check the lower bound before doing
// that.
if i.lower != nil && i.cmp(indexKey.K.UserKey, i.lower) < 0 {
i.exhaustedBounds = -1
return nil
}
continue
}
if i.blockLower != nil && i.cmp(kv.K.UserKey, i.blockLower) < 0 {
i.exhaustedBounds = -1
Expand Down
18 changes: 18 additions & 0 deletions sstable/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,17 @@ func TestReaderHideObsolete(t *testing.T) {
t, opts, "testdata/reader_hide_obsolete",
nil /* Reader */, true)
})
opts = WriterOptions{
TableFormat: TableFormatPebblev4,
BlockSize: blockSize,
IndexBlockSize: 1 << 30, // Force a single-level index block.
Comparer: testkeys.Comparer,
}
t.Run(fmt.Sprintf("singleLevel/blockSize=%s", dName), func(t *testing.T) {
runTestReader(
t, opts, "testdata/reader_hide_obsolete",
nil /* Reader */, true)
})
}
}

Expand Down Expand Up @@ -797,6 +808,13 @@ func runTestReader(t *testing.T, o WriterOptions, dir string, r *Reader, printVa
require.True(t, retHideObsoletePoints)
}
}
if d.HasArg("hide-obsolete-points-without-filter") {
var hideObsoletePoints bool
d.ScanArgs(t, "hide-obsolete-points-without-filter", &hideObsoletePoints)
if hideObsoletePoints {
transforms.HideObsoletePoints = true
}
}
var filterer *BlockPropertiesFilterer
if len(bpfs) > 0 {
filterer = newBlockPropertiesFilterer(bpfs, nil, nil)
Expand Down
26 changes: 26 additions & 0 deletions sstable/testdata/reader_hide_obsolete/iter
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,29 @@ d.SINGLEDEL.40:
d.MERGE.30:D30
----
MERGE not supported in a strict-obsolete sstable

# Regression test for #3761. If an entire block contains obsolete points,
# skipBackward should still skip to blocks earlier in the sstable.

build writing-to-lowest-level
a.SET.10:A10
force-obsolete: b.DEL.5:
force-obsolete: b.SETWITHDEL.2:foo
force-obsolete: c.DEL.0:
force-obsolete: cc.DEL.5:
----

iter hide-obsolete-points-without-filter=true
last
----
<a:10>:A10

iter hide-obsolete-points-without-filter=true
seek-lt d
----
<a:10>:A10

iter hide-obsolete-points-without-filter=true
seek-lt c
----
<a:10>:A10
Loading