nit change

Signed-off-by: husharp <jinhao.hu@pingcap.com>
This commit is contained in:
husharp 2023-08-21 10:26:21 +08:00
parent cedc94b3ee
commit 97f9c1835b
2 changed files with 10 additions and 10 deletions

View File

@ -37,8 +37,6 @@ package tikv_test
import (
"context"
"fmt"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/tikv/client-go/v2/config"
"strings"
"sync/atomic"
"testing"
@ -46,7 +44,9 @@ import (
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/stretchr/testify/suite"
"github.com/tikv/client-go/v2/config"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
@ -105,9 +105,9 @@ func (c *storeSafeTsMockClient) CloseAddr(addr string) error {
return c.Client.CloseAddr(addr)
}
func (s *apiTestSuite) TestGetStoreMinResolvedTS() {
func (s *apiTestSuite) TestGetClusterMinResolvedTS() {
util.EnableFailpoints()
// Try to get the minimum resolved timestamp of the store from PD.
// Try to get the minimum resolved timestamp of the cluster from PD.
require := s.Require()
require.Nil(failpoint.Enable("tikvclient/InjectMinResolvedTS", `return(100)`))
mockClient := storeSafeTsMockClient{
@ -126,7 +126,7 @@ func (s *apiTestSuite) TestGetStoreMinResolvedTS() {
require.Equal(uint64(100), s.store.GetMinSafeTS(oracle.GlobalTxnScope))
require.Nil(failpoint.Disable("tikvclient/InjectMinResolvedTS"))
// Try to get the minimum resolved timestamp of the store from TiKV.
// Try to get the minimum resolved timestamp of the cluster from TiKV.
require.Nil(failpoint.Enable("tikvclient/InjectMinResolvedTS", `return(0)`))
defer func() {
s.Require().Nil(failpoint.Disable("tikvclient/InjectMinResolvedTS"))

View File

@ -580,8 +580,8 @@ func (s *KVStore) safeTSUpdater() {
}
func (s *KVStore) updateSafeTS(ctx context.Context) {
// Try getting the cluster-level minimum resolved timestamp from PD first.
if s.setGlobalMinSafeTSByPD(ctx) {
// Try to get the cluster-level minimum resolved timestamp from PD first.
if s.setClusterMinSafeTSByPD(ctx) {
return
}
@ -675,8 +675,8 @@ var (
clusterMinSafeTSGap = metrics.TiKVMinSafeTSGapSeconds.WithLabelValues("cluster")
)
// setGlobalMinSafeTSByPD check whether it is needed to get cluster-level's min resolved ts from PD.
func (s *KVStore) setGlobalMinSafeTSByPD(ctx context.Context) bool {
// setClusterMinSafeTSByPD check whether it is needed to get cluster-level's min resolved ts from PD.
func (s *KVStore) setClusterMinSafeTSByPD(ctx context.Context) bool {
isGlobal := config.GetTxnScopeFromConfig() == oracle.GlobalTxnScope
// Try to get the minimum resolved timestamp of the cluster from PD.
if s.pdHttpClient != nil && isGlobal {
@ -684,7 +684,7 @@ func (s *KVStore) setGlobalMinSafeTSByPD(ctx context.Context) bool {
if err != nil {
logutil.BgLogger().Debug("get resolved TS from PD failed", zap.Error(err))
} else if clusterMinSafeTS != 0 {
// update metrics.
// Update metrics.
preClusterMinSafeTS := s.GetMinSafeTS(oracle.GlobalTxnScope)
if preClusterMinSafeTS > clusterMinSafeTS {
skipSafeTSUpdateCounter.Inc()