@@ -299,7 +299,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
299
299
region = & Region {
300
300
meta : region .GetMeta (),
301
301
}
302
- region .lastAccess = time .Now ().Unix ()
302
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
303
303
region .meta .Peers = append (region .meta .Peers , peer )
304
304
atomic .StorePointer (& region .store , unsafe .Pointer (regionStore ))
305
305
@@ -374,7 +374,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
374
374
s .False (replicaSelector .region .isValid ())
375
375
376
376
// Test switching to tryFollower if leader is unreachable
377
- region .lastAccess = time .Now ().Unix ()
377
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
378
378
replicaSelector , err = newReplicaSelector (cache , regionLoc .Region , req )
379
379
s .Nil (err )
380
380
s .NotNil (replicaSelector )
@@ -563,7 +563,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
563
563
assertRPCCtxEqual (rpcCtx , replicaSelector .replicas [regionStore .workTiKVIdx ], nil )
564
564
565
565
// Test accessFollower state filtering label-not-match stores.
566
- region .lastAccess = time .Now ().Unix ()
566
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
567
567
refreshEpochs (regionStore )
568
568
labels := []* metapb.StoreLabel {
569
569
{
@@ -585,7 +585,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
585
585
}
586
586
587
587
// Test accessFollower state with leaderOnly option
588
- region .lastAccess = time .Now ().Unix ()
588
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
589
589
refreshEpochs (regionStore )
590
590
for i := 0 ; i < 5 ; i ++ {
591
591
replicaSelector , err = newReplicaSelector (cache , regionLoc .Region , req , WithLeaderOnly ())
@@ -598,15 +598,15 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
598
598
}
599
599
600
600
// Test accessFollower state with kv.ReplicaReadMixed request type.
601
- region .lastAccess = time .Now ().Unix ()
601
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
602
602
refreshEpochs (regionStore )
603
603
req .ReplicaReadType = kv .ReplicaReadMixed
604
604
replicaSelector , err = newReplicaSelector (cache , regionLoc .Region , req )
605
605
s .NotNil (replicaSelector )
606
606
s .Nil (err )
607
607
608
608
// Invalidate the region if the leader is not in the region.
609
- region .lastAccess = time .Now ().Unix ()
609
+ atomic . StoreInt64 ( & region .lastAccess , time .Now ().Unix () )
610
610
replicaSelector .updateLeader (& metapb.Peer {Id : s .cluster .AllocID (), StoreId : s .cluster .AllocID ()})
611
611
s .False (region .isValid ())
612
612
// Don't try next replica if the region is invalidated.
0 commit comments