You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a NotLeader error carrying a new leader info is received from TiKV, we update the leader info of the region by updating the struct Region 's store field which is in type RegionStore). As the Region is a type of shared data managed by RegionCache, the store is updated by replacing atomic pointers, and thus RegionStore is used in copy-on-write pattern.
This will cause backoff to the caller of SendReqCtx, which is unnecessary in a NotLeader case where the new leader is immediately known.
The usage of invalidStore introduced by #264 mentioned above looks expected to compare whether the store field of the old and new regionStore instances points to the same block of memory, but mistakenly compared the address of the store field itself.
The text was updated successfully, but these errors were encountered:
When a
NotLeader
error carrying a new leader info is received from TiKV, we update the leader info of the region by updating the structRegion
'sstore
field which is in typeRegionStore
). As theRegion
is a type of shared data managed byRegionCache
, thestore
is updated by replacing atomic pointers, and thusRegionStore
is used in copy-on-write pattern.client-go/internal/locate/region_cache.go
Lines 2451 to 2454 in abda04c
Then, #264 introduces this which is executed every time attempting to send a request:
client-go/internal/locate/region_request.go
Lines 1023 to 1026 in abda04c
This forces the replicaSelector to be rebuilt when retrying on
NotLeader
error, by return nil rpcCtx:client-go/internal/locate/region_request.go
Lines 894 to 897 in abda04c
and then triggering pseudo region error:
client-go/internal/locate/region_request.go
Lines 1424 to 1435 in abda04c
This will cause backoff to the caller of
SendReqCtx
, which is unnecessary in aNotLeader
case where the new leader is immediately known.The usage of
invalidStore
introduced by #264 mentioned above looks expected to compare whether thestore
field of the old and newregionStore
instances points to the same block of memory, but mistakenly compared the address of thestore
field itself.The text was updated successfully, but these errors were encountered: