Skip to content

Commit

Permalink
Merge pull request #18274 from fuweid/fix-event-loss-caused-by-compact
Browse files Browse the repository at this point in the history
*: keep tombstone if revision == compactAtRev
  • Loading branch information
ahrtr authored Aug 16, 2024
2 parents 39b711f + bbdc941 commit 1d0a6b3
Show file tree
Hide file tree
Showing 5 changed files with 672 additions and 114 deletions.
14 changes: 14 additions & 0 deletions server/storage/mvcc/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func (h *kvHasher) WriteKeyValue(k, v []byte) {
if !upper.GreaterThan(kr) {
return
}

isTombstone := BytesToBucketKey(k).tombstone

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 @@ -71,6 +74,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 && isTombstone {
return
}

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

0 comments on commit 1d0a6b3

Please sign in to comment.