From 15f80af9f4c74058d7b7f9906eea9ad6ecc133ba Mon Sep 17 00:00:00 2001 From: JmPotato Date: Wed, 14 Aug 2024 11:36:07 +0800 Subject: [PATCH 1/2] Fix an invalid err != nil check Signed-off-by: JmPotato --- pkg/tso/keyspace_group_manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/tso/keyspace_group_manager.go b/pkg/tso/keyspace_group_manager.go index 79521e90e8f..c4930479030 100644 --- a/pkg/tso/keyspace_group_manager.go +++ b/pkg/tso/keyspace_group_manager.go @@ -1362,9 +1362,9 @@ func (kgm *KeyspaceGroupManager) mergingChecker(ctx context.Context, mergeTarget zap.Any("merge-list", mergeList)) // All the keyspace group primaries in the merge list are gone, // calculate the newly merged TSO to make sure it is greater than the original ones. - var mergedTS time.Time + var ts, mergedTS time.Time for _, id := range mergeList { - ts, err := kgm.tsoSvcStorage.LoadTimestamp(endpoint.KeyspaceGroupGlobalTSPath(id)) + ts, err = kgm.tsoSvcStorage.LoadTimestamp(endpoint.KeyspaceGroupGlobalTSPath(id)) if err != nil { log.Error("failed to load the keyspace group TSO", zap.String("member", kgm.tsoServiceID.ServiceAddr), From 689a4807f8414cb1ea5028fea985a058e1e7bc70 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Wed, 14 Aug 2024 11:55:05 +0800 Subject: [PATCH 2/2] Use continue lable instead of break Signed-off-by: JmPotato --- pkg/tso/keyspace_group_manager.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/tso/keyspace_group_manager.go b/pkg/tso/keyspace_group_manager.go index c4930479030..5a2c908ec2e 100644 --- a/pkg/tso/keyspace_group_manager.go +++ b/pkg/tso/keyspace_group_manager.go @@ -1302,6 +1302,7 @@ func (kgm *KeyspaceGroupManager) mergingChecker(ctx context.Context, mergeTarget mergeMap[id] = struct{}{} } +mergeLoop: for { select { case <-ctx.Done(): @@ -1362,9 +1363,9 @@ func (kgm *KeyspaceGroupManager) mergingChecker(ctx context.Context, mergeTarget zap.Any("merge-list", mergeList)) // All the keyspace group primaries in the merge list are gone, // calculate the newly merged TSO to make sure it is greater than the original ones. - var ts, mergedTS time.Time + var mergedTS time.Time for _, id := range mergeList { - ts, err = kgm.tsoSvcStorage.LoadTimestamp(endpoint.KeyspaceGroupGlobalTSPath(id)) + ts, err := kgm.tsoSvcStorage.LoadTimestamp(endpoint.KeyspaceGroupGlobalTSPath(id)) if err != nil { log.Error("failed to load the keyspace group TSO", zap.String("member", kgm.tsoServiceID.ServiceAddr), @@ -1373,15 +1374,13 @@ func (kgm *KeyspaceGroupManager) mergingChecker(ctx context.Context, mergeTarget zap.Uint32("merge-id", id), zap.Time("ts", ts), zap.Error(err)) - break + // Retry from the beginning of the loop. + continue mergeLoop } if ts.After(mergedTS) { mergedTS = ts } } - if err != nil { - continue - } // Update the newly merged TSO if the merged TSO is not zero. if mergedTS != typeutil.ZeroTime { log.Info("start to set the newly merged TSO",