Skip to content

Commit

Permalink
db: fix newly-introduced SINGLEDEL+DELSIZED bug
Browse files Browse the repository at this point in the history
In bfb2e6a (#3081) a small refactor the handling of DELSIZED introduced a bug
when a DELSIZED shadows a SINGLEDEL. When a DELSIZED and a SINGLEDEL meet in a
compaction, we began accidentally emitting a SINGLEDEL rather than a DEL,
weakening the tombstone. Previously the problematic code branch was only ever
executed when a DELSIZED and DEL met, so iterKey.Kind() was always DEL.

Fix #3087.
  • Loading branch information
jbowens committed Nov 19, 2023
1 parent 717d49c commit b9be64b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compaction_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ func (i *compactionIter) deleteSizedNext() (*base.InternalKey, []byte) {
// plus we don't want to count it as a missized DEL. We early
// exit in this case, after skipping the remainder of the
// snapshot stripe.
i.key.SetKind(i.iterKey.Kind())
i.key.SetKind(InternalKeyKindDelete)
// NB: We skipInStripe now, rather than returning leaving
// i.skip=true and returning early, because Next() requires
// that i.skip=true only if i.iterPos = iterPosCurForward.
Expand Down
19 changes: 19 additions & 0 deletions testdata/compaction_iter_delete_sized
Original file line number Diff line number Diff line change
Expand Up @@ -1860,3 +1860,22 @@ next
a#5,0:
.
missized-dels=0

# Regression test for #3087.
#
# Whne a DELSIZED and a SINGLEDEL meet in a compaction, a DEL key should be
# emitted.

define
a.DELSIZED.5:
a.SINGLEDEL.3:
a.SET.2:foo
a.SET.1:bar
----

iter
first
next
----
a#5,0:
.

0 comments on commit b9be64b

Please sign in to comment.