Skip to content

Commit

Permalink
Merge branch 'master' into fix-trace
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored Oct 26, 2023
2 parents b80285c + 459671f commit 138b10b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ type Cluster struct {
running atomic.Bool
}

const regionLabelGCInterval = time.Hour
const (
regionLabelGCInterval = time.Hour
requestTimeout = 3 * time.Second
)

// NewCluster creates a new cluster.
func NewCluster(parentCtx context.Context, persistConfig *config.PersistConfig, storage storage.Storage, basicCluster *core.BasicCluster, hbStreams *hbstream.HeartbeatStreams, clusterID uint64, checkMembershipCh chan struct{}) (*Cluster, error) {
Expand Down Expand Up @@ -199,7 +202,9 @@ func (c *Cluster) AllocID() (uint64, error) {
if err != nil {
return 0, err
}
resp, err := client.AllocID(c.ctx, &pdpb.AllocIDRequest{Header: &pdpb.RequestHeader{ClusterId: c.clusterID}})
ctx, cancel := context.WithTimeout(c.ctx, requestTimeout)
defer cancel()
resp, err := client.AllocID(ctx, &pdpb.AllocIDRequest{Header: &pdpb.RequestHeader{ClusterId: c.clusterID}})
if err != nil {
c.checkMembershipCh <- struct{}{}
return 0, err
Expand Down

0 comments on commit 138b10b

Please sign in to comment.