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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c h1:FawoWiQL45zu3sJxO0obrXW4bLB4rwpktXGU5kLyyaM=
github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
Expand Down
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 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
2 changes: 2 additions & 0 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c h1:FawoWiQL45zu3sJxO0obrXW4bLB4rwpktXGU5kLyyaM=
github.com/LykxSassinator/kvproto v0.0.0-20250109105336-7099a32e318c/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
Expand Down
Loading