From f9e789f1a0e52bf882a681d67e1415338f3c9d50 Mon Sep 17 00:00:00 2001 From: hugy718 Date: Thu, 27 Apr 2023 16:43:38 +0800 Subject: [PATCH] change split key range right key to use ts=0 --- levels.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/levels.go b/levels.go index 387ee7e3e..08c6cbe7b 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 + // Right is assigned ts=0. The encoding ts bytes takes maxuin64-ts. + // So, for the same key, smaller TS will be considered larger // in subcompaction. 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) + // This will generate splits like [A1 ... C0], including any records of Key C. + right := y.KeyWithTs(y.ParseKey(t.Biggest()), 0) addRange(right) } }