Skip to content

Commit

Permalink
use atomic to read epoch
Browse files Browse the repository at this point in the history
Signed-off-by: cfzjywxk <[email protected]>
  • Loading branch information
cfzjywxk committed Aug 11, 2023
1 parent 51e2fbd commit 826a612
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ type replica struct {
deadlineErrUsingConfTimeout bool
}

func (r *replica) getEpoch() uint32 {
return atomic.LoadUint32(&r.epoch)
}

func (r *replica) isEpochStale() bool {
return r.epoch != atomic.LoadUint32(&r.store.epoch)
}
Expand Down Expand Up @@ -324,7 +328,7 @@ func (s *replicaSelector) String() string {
replica.store.storeID,
replica.isEpochStale(),
replica.attempts,
replica.epoch,
replica.getEpoch(),
atomic.LoadUint32(&replica.store.epoch),
replica.store.getResolveState(),
replica.store.getLivenessState(),
Expand Down

0 comments on commit 826a612

Please sign in to comment.