Skip to content
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

cluster: return NodeState in the response of StoreHeartbeat. #8991

Merged
merged 13 commits into from
Jan 17, 2025
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,5 @@ require (
moul.io/zapgorm2 v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c
1,716 changes: 1,707 additions & 9 deletions go.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,10 @@ func (c *RaftCluster) HandleStoreHeartbeat(heartbeat *pdpb.StoreHeartbeatRequest
if store := c.GetStore(storeID); store != nil {
statistics.UpdateStoreHeartbeatMetrics(store)
}
// Supply NodeState in the response to help the store handle special cases
// more conveniently, such as avoiding calling `remove_peer` redundantly under
// NodeState_Removing.
resp.State = store.GetNodeState()
c.PutStore(newStore)
var (
regions map[uint64]*core.RegionInfo
Expand Down
1 change: 1 addition & 0 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func TestStoreHeartbeat(t *testing.T) {
re.NotEqual(int64(0), s.GetLastHeartbeatTS().UnixNano())
re.Equal(req.GetStats(), s.GetStoreStats())
re.Equal("v2", cluster.GetStore(1).GetStoreLimit().Version())
re.Equal(s.GetMeta().GetNodeState(), resp.GetState())

storeMetasAfterHeartbeat = append(storeMetasAfterHeartbeat, s.GetMeta())
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integrations/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,5 @@ require (
gorm.io/driver/sqlite v1.4.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c
1,719 changes: 1,710 additions & 9 deletions tests/integrations/go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,5 @@ require (
moul.io/zapgorm2 v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c
1,719 changes: 1,709 additions & 10 deletions tools/go.sum

Large diffs are not rendered by default.

Loading