diff --git a/integration_tests/store_test.go b/integration_tests/store_test.go index 44b737a9..8aa7b1aa 100644 --- a/integration_tests/store_test.go +++ b/integration_tests/store_test.go @@ -118,6 +118,9 @@ type checkRequestClient struct { func (c *checkRequestClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) { resp, err := c.Client.SendRequest(ctx, addr, req, timeout) + if err != nil { + return resp, err + } if c.priority != req.Priority { if resp.Resp != nil { if getResp, ok := resp.Resp.(*kvrpcpb.GetResponse); ok { diff --git a/internal/locate/region_request3_test.go b/internal/locate/region_request3_test.go index 79e40141..319bddc2 100644 --- a/internal/locate/region_request3_test.go +++ b/internal/locate/region_request3_test.go @@ -314,7 +314,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() { region = &Region{ meta: region.GetMeta(), } - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) region.meta.Peers = append(region.meta.Peers, tikvLearner) atomic.StorePointer(®ion.store, unsafe.Pointer(regionStore)) @@ -325,7 +325,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() { cache.mu.Unlock() // Test accessFollower state with kv.ReplicaReadLearner request type. - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) refreshEpochs(regionStore) req.ReplicaReadType = kv.ReplicaReadLearner replicaSelector, err := newReplicaSelector(cache, regionLoc.Region, req) @@ -334,7 +334,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() { accessLearner, _ := replicaSelector.state.(*accessFollower) // Invalidate the region if the leader is not in the region. - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) rpcCtx, err := replicaSelector.next(s.bo) s.Nil(err) // Should swith to the next follower. @@ -365,7 +365,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { region = &Region{ meta: region.GetMeta(), } - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) region.meta.Peers = append(region.meta.Peers, tiflash) atomic.StorePointer(®ion.store, unsafe.Pointer(regionStore)) @@ -429,7 +429,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { s.False(replicaSelector.region.isValid()) // Test switching to tryFollower if leader is unreachable - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req) s.Nil(err) s.NotNil(replicaSelector) @@ -613,7 +613,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { AssertRPCCtxEqual(s, rpcCtx, replicaSelector.replicas[regionStore.workTiKVIdx], nil) // Test accessFollower state filtering label-not-match stores. - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) refreshEpochs(regionStore) labels := []*metapb.StoreLabel{ { @@ -635,7 +635,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { } // Test accessFollower state with leaderOnly option - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) refreshEpochs(regionStore) for i := 0; i < 5; i++ { replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req, WithLeaderOnly()) @@ -648,7 +648,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { } // Test accessFollower state with kv.ReplicaReadMixed request type. - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) refreshEpochs(regionStore) req.ReplicaReadType = kv.ReplicaReadMixed replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req) @@ -656,7 +656,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() { s.Nil(err) // Invalidate the region if the leader is not in the region. - region.lastAccess = time.Now().Unix() + atomic.StoreInt64(®ion.lastAccess, time.Now().Unix()) replicaSelector.updateLeader(&metapb.Peer{Id: s.cluster.AllocID(), StoreId: s.cluster.AllocID()}) s.False(region.isValid()) // Don't try next replica if the region is invalidated.