Skip to content

Commit

Permalink
Merge branch 'master' into sche-redirect7
Browse files Browse the repository at this point in the history
  • Loading branch information
lhy1024 authored Oct 30, 2023
2 parents bbfb40b + 744e51d commit 9f5a73b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ func (r *RegionsInfo) GetStoreWriteRate(storeID uint64) (bytesRate, keysRate flo

// GetClusterNotFromStorageRegionsCnt gets the total count of regions that not loaded from storage anymore
func (r *RegionsInfo) GetClusterNotFromStorageRegionsCnt() int {
r.st.RLock()
defer r.st.RUnlock()
r.t.RLock()
defer r.t.RUnlock()
return r.tree.notFromStorageRegionsCnt
}

Expand Down
11 changes: 9 additions & 2 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (c *Cluster) AllocID() (uint64, error) {
defer cancel()
resp, err := client.AllocID(ctx, &pdpb.AllocIDRequest{Header: &pdpb.RequestHeader{ClusterId: c.clusterID}})
if err != nil {
c.checkMembershipCh <- struct{}{}
c.triggerMembershipCheck()
return 0, err
}
return resp.GetId(), nil
Expand All @@ -215,12 +215,19 @@ func (c *Cluster) AllocID() (uint64, error) {
func (c *Cluster) getAPIServerLeaderClient() (pdpb.PDClient, error) {
cli := c.apiServerLeader.Load()
if cli == nil {
c.checkMembershipCh <- struct{}{}
c.triggerMembershipCheck()
return nil, errors.New("API server leader is not found")
}
return cli.(pdpb.PDClient), nil
}

func (c *Cluster) triggerMembershipCheck() {
select {
case c.checkMembershipCh <- struct{}{}:
default: // avoid blocking
}
}

// SwitchAPIServerLeader switches the API server leader.
func (c *Cluster) SwitchAPIServerLeader(new pdpb.PDClient) bool {
old := c.apiServerLeader.Load()
Expand Down

0 comments on commit 9f5a73b

Please sign in to comment.