From 803bc9001a06f2426d1e01645335593ccc5c1bfa Mon Sep 17 00:00:00 2001 From: hugy718 Date: Fri, 28 Apr 2023 16:50:54 +0800 Subject: [PATCH] change split key range right key to use ts=0 --- levels.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/levels.go b/levels.go index 387ee7e3e..04aa04dc6 100644 --- a/levels.go +++ b/levels.go @@ -1073,14 +1073,13 @@ func (s *levelsController) addSplits(cd *compactDef) { return } if i%width == width-1 { - // Right should always have ts=maxUint64 otherwise we'll lose keys - // in subcompaction. Consider the following. + // Right is assigned ts=0. The encoding ts bytes take MaxUint64-ts, + // so, those with smaller TS will be considered larger for the same key. + // Consider the following. // Top table is [A1...C3(deleted)] // bot table is [B1....C2] - // This will generate splits like [A1 ... C2] . Notice that we - // dropped the C3 which is the last key of the top table. - // See TestCompaction/with_split test. - right := y.KeyWithTs(y.ParseKey(t.Biggest()), math.MaxUint64) + // It will generate a split [A1 ... C0], including any records of Key C. + right := y.KeyWithTs(y.ParseKey(t.Biggest()), 0) addRange(right) } }