-
Notifications
You must be signed in to change notification settings - Fork 726
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
*: fix scheduling can not immediately start after transfer leader #4875
Changes from 6 commits
f819458
57c998c
7285fb8
bf2b5e0
54e8fc1
0d38ff3
04b24dd
f297bf2
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 |
---|---|---|
|
@@ -61,7 +61,8 @@ type RegionInfo struct { | |
QueryStats *pdpb.QueryStats | ||
flowRoundDivisor uint64 | ||
// buckets is not thread unsafe, it should be accessed by the request `report buckets` with greater version. | ||
buckets unsafe.Pointer | ||
buckets unsafe.Pointer | ||
fromHeartbeat bool | ||
} | ||
|
||
// NewRegionInfo creates RegionInfo with region's meta and leader peer. | ||
|
@@ -540,6 +541,11 @@ func (r *RegionInfo) GetReplicationStatus() *replication_modepb.RegionReplicatio | |
return r.replicationStatus | ||
} | ||
|
||
// IsFromHeartbeat returns whether the region info is from the region heartbeat. | ||
func (r *RegionInfo) IsFromHeartbeat() bool { | ||
return r.fromHeartbeat | ||
} | ||
|
||
// RegionGuideFunc is a function that determines which follow-up operations need to be performed based on the origin | ||
// and new region information. | ||
type RegionGuideFunc func(region, origin *RegionInfo) (isNew, saveKV, saveCache, needSync bool) | ||
|
@@ -624,6 +630,9 @@ func GenerateRegionGuideFunc(enableLog bool) RegionGuideFunc { | |
region.GetReplicationStatus().GetStateId() != origin.GetReplicationStatus().GetStateId()) { | ||
saveCache = true | ||
} | ||
if !origin.IsFromHeartbeat() { | ||
isNew = true | ||
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. Should we set |
||
} | ||
} | ||
return | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,9 +204,10 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) { | |
core.SetWrittenKeys(stats[i].KeysWritten), | ||
core.SetReadBytes(stats[i].BytesRead), | ||
core.SetReadKeys(stats[i].KeysRead), | ||
core.SetFromHeartbeat(false), | ||
) | ||
} else { | ||
region = core.NewRegionInfo(r, regionLeader) | ||
region = core.NewRegionInfo(r, regionLeader, core.SetFromHeartbeat(false)) | ||
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. It seems we do not need to
|
||
} | ||
|
||
origin, err := bc.PreCheckPutRegion(region) | ||
|
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.
Could we check the condition in the function
collect
directly?