Skip to content

Commit

Permalink
Merge pull request #18474 from fuweid/35-backport-18274-part3
Browse files Browse the repository at this point in the history
[3.5] *: keep tombstone if revision == compactAtRev
  • Loading branch information
ahrtr authored Aug 21, 2024
2 parents 400c2d3 + 8d98510 commit 7749649
Show file tree
Hide file tree
Showing 5 changed files with 680 additions and 112 deletions.
14 changes: 14 additions & 0 deletions server/mvcc/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (h *kvHasher) WriteKeyValue(k, v []byte) {
if !upper.GreaterThan(kr) {
return
}

isTombstoneRev := isTombstone(k)

lower := revision{main: h.compactRevision + 1}
// skip revisions that are scheduled for deletion
// due to compacting; don't skip if there isn't one.
Expand All @@ -70,6 +73,17 @@ func (h *kvHasher) WriteKeyValue(k, v []byte) {
return
}
}

// When performing compaction, if the compacted revision is a
// tombstone, older versions (<= 3.5.15 or <= 3.4.33) will delete
// the tombstone. But newer versions (> 3.5.15 or > 3.4.33) won't
// delete it. So we should skip the tombstone in such cases when
// computing the hash to ensure that both older and newer versions
// can always generate the same hash values.
if kr.main == h.compactRevision && isTombstoneRev {
return
}

h.hash.Write(k)
h.hash.Write(v)
}
Expand Down
Loading

0 comments on commit 7749649

Please sign in to comment.