From 6cad3303c084f3b4146827df2deb9ca3a195e580 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 31 Jan 2024 10:56:55 +0800 Subject: [PATCH] *: remove redundant go_test Signed-off-by: Weizhen Wang --- internal/locate/region_cache.go | 9 +++++---- internal/locate/region_request.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go index 3d4da94d2..822a0eb93 100644 --- a/internal/locate/region_cache.go +++ b/internal/locate/region_cache.go @@ -66,6 +66,7 @@ import ( "github.com/tikv/client-go/v2/tikvrpc" "github.com/tikv/client-go/v2/util" pd "github.com/tikv/pd/client" + atomic2 "go.uber.org/atomic" "go.uber.org/zap" "golang.org/x/sync/singleflight" "google.golang.org/grpc" @@ -175,7 +176,7 @@ type regionStore struct { // accessIndex[tiKVOnly][proxyTiKVIdx] is the index of TiKV that can forward requests to the leader in stores, -1 means not using proxy. proxyTiKVIdx AccessIndex // accessIndex[tiFlashOnly][workTiFlashIdx] is the index of the current working TiFlash in stores. - workTiFlashIdx atomic.Int32 + workTiFlashIdx atomic2.Int32 // buckets is not accurate and it can change even if the region is not changed. // It can be stale and buckets keys can be out of the region range. buckets *metapb.Buckets @@ -998,7 +999,7 @@ func (l *KeyLocation) locateBucket(key []byte) *Bucket { keys := l.Buckets.GetKeys() searchLen := len(keys) - 1 i, found := slices.BinarySearchFunc(keys, key, func(a, b []byte) int { - return -bytes.Compare(a, b) + return bytes.Compare(a, b) }) // buckets contains region's start/end key, so i==0 means it can't find a suitable bucket @@ -2420,9 +2421,9 @@ type Store struct { resolveMutex sync.Mutex // protect pd from concurrent init requests epoch uint32 // store fail epoch, see RegionStore.storeEpochs storeType tikvrpc.EndpointType // type of the store - tokenCount atomic.Int64 // used store token count + tokenCount atomic2.Int64 // used store token count - loadStats atomic.Pointer[storeLoadStats] + loadStats atomic2.Pointer[storeLoadStats] // whether the store is unreachable due to some reason, therefore requests to the store needs to be // forwarded by other stores. this is also the flag that a checkUntilHealth goroutine is running for this store. diff --git a/internal/locate/region_request.go b/internal/locate/region_request.go index 473d6eb14..d839d5342 100644 --- a/internal/locate/region_request.go +++ b/internal/locate/region_request.go @@ -1810,7 +1810,7 @@ func (s *RegionRequestSender) releaseStoreToken(st *Store) { count := st.tokenCount.Load() // Decreasing tokenCount is no thread safe, preferring this for avoiding check in loop. if count > 0 { - st.tokenCount.Add(-1) + st.tokenCount.Sub(1) return } logutil.BgLogger().Warn("release store token failed, count equals to 0")