From 5ea42dbe19872330b61687987cf504f8ffc690ce Mon Sep 17 00:00:00 2001 From: JmPotato Date: Wed, 21 Jun 2023 13:35:42 +0800 Subject: [PATCH] tso: fix checkTSOSplit to finish split correctly (#6652) ref tikv/pd#6232 Fix `checkTSOSplit` to finish split correctly. Signed-off-by: JmPotato Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- pkg/tso/keyspace_group_manager.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/tso/keyspace_group_manager.go b/pkg/tso/keyspace_group_manager.go index 62a6986422c6..1ec3e7ffcc3c 100644 --- a/pkg/tso/keyspace_group_manager.go +++ b/pkg/tso/keyspace_group_manager.go @@ -837,23 +837,31 @@ func (kgm *KeyspaceGroupManager) checkTSOSplit( if err != nil { return err } + // If the split source TSO is not greater than the newly split TSO, we don't need to do anything. if tsoutil.CompareTimestamp(&splitSourceTSO, &splitTSO) <= 0 { - log.Debug("the split source TSO is not greater than the newly split TSO", + log.Info("the split source tso is less than the newly split tso", zap.Int64("split-source-tso-physical", splitSourceTSO.Physical), zap.Int64("split-source-tso-logical", splitSourceTSO.Logical), zap.Int64("split-tso-physical", splitTSO.Physical), - zap.Int64("split-tso-logical", splitTSO.Logical), - ) - return nil + zap.Int64("split-tso-logical", splitTSO.Logical)) + // Finish the split state directly. + return kgm.finishSplitKeyspaceGroup(keyspaceGroupID) } // If the split source TSO is greater than the newly split TSO, we need to update the split // TSO to make sure the following TSO will be greater than the split keyspaces ever had // in the past. - splitSourceTSO.Physical += 1 - err = splitAllocator.SetTSO(tsoutil.GenerateTS(&splitSourceTSO), true, true) + err = splitAllocator.SetTSO(tsoutil.GenerateTS(&pdpb.Timestamp{ + Physical: splitSourceTSO.Physical + 1, + Logical: splitSourceTSO.Logical, + }), true, true) if err != nil { return err } + log.Info("the split source tso is greater than the newly split tso", + zap.Int64("split-source-tso-physical", splitSourceTSO.Physical), + zap.Int64("split-source-tso-logical", splitSourceTSO.Logical), + zap.Int64("split-tso-physical", splitTSO.Physical), + zap.Int64("split-tso-logical", splitTSO.Logical)) // Finish the split state. return kgm.finishSplitKeyspaceGroup(keyspaceGroupID) }