Skip to content

Commit

Permalink
*: remove redundant go_test
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Feb 23, 2024
1 parent 13548a4 commit 1955d35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions internal/locate/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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"
Expand Down Expand Up @@ -218,7 +219,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
Expand Down Expand Up @@ -1048,7 +1049,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
Expand Down Expand Up @@ -2510,9 +2511,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.
Expand Down
2 changes: 1 addition & 1 deletion internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,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")
Expand Down

0 comments on commit 1955d35

Please sign in to comment.