-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reload region cache when store is resolved from invalid status #843
Changes from 3 commits
bb30b61
5119e70
9f798e2
ba45117
deb5a88
696a06a
753346d
818e1c7
ba1eaef
7703c17
034f36e
84e83df
7a73a23
55915dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,18 +573,22 @@ func (state *accessFollower) next(bo *retry.Backoffer, selector *replicaSelector | |
if state.option.preferLeader { | ||
state.lastIdx = state.leaderIdx | ||
} | ||
offset := rand.Intn(replicaSize) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I changed the code and not to use offset in the first selection. |
||
for i := 0; i < replicaSize && !state.option.leaderOnly; i++ { | ||
idx := AccessIndex((int(state.lastIdx) + i) % replicaSize) | ||
// If the given store is abnormal to be accessed under `ReplicaReadMixed` mode, we should choose other followers or leader | ||
// as candidates to serve the Read request. Meanwhile, we should make the choice of next() meet Uniform Distribution. | ||
for cnt := 0; cnt < replicaSize && !state.isCandidate(idx, selector.replicas[idx]); cnt++ { | ||
idx = AccessIndex((int(idx) + rand.Intn(replicaSize)) % replicaSize) | ||
} | ||
if state.isCandidate(idx, selector.replicas[idx]) { | ||
idx := AccessIndex((int(state.lastIdx) + i + offset) % replicaSize) | ||
selectReplica := selector.replicas[idx] | ||
if state.isCandidate(idx, selectReplica) { | ||
state.lastIdx = idx | ||
selector.targetIdx = idx | ||
break | ||
} | ||
if selectReplica.isEpochStale() && | ||
selectReplica.store.getResolveState() == resolved && | ||
selectReplica.store.getLivenessState() == reachable { | ||
selector.regionCache.asyncReloadRegion(selector.region) | ||
} | ||
} | ||
// If there is no candidate, fallback to the leader. | ||
if selector.targetIdx < 0 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be risky to spawn a reload task for each region, especially if many regions become invalid due to the related store being marked as such. To mitigate this risk, we should implement a refreshing strategy in the region cache-related workers and consider incorporating the store's "health checker."
@crazycs520 is now considering refactoring the region cache component, he could give some advice about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the v6.5.x release version, a quick fix may still be needed.