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

metrics: fix operator timeout metrics #1541

Merged
merged 2 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func (c *RaftCluster) checkOperators() {
log.Info("operator timeout",
zap.Uint64("region-id", op.RegionID()),
zap.Stringer("operator", op))
opController.RemoveOperator(op)
opController.RemoveTimeoutOperator(op)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion server/schedule/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ func (o *Operator) IsTimeout() bool {
timeout = time.Since(o.createTime) > LeaderOperatorWaitTime
}
if timeout {
operatorCounter.WithLabelValues(o.Desc(), "timeout").Inc()
return true
}
return false
Expand Down
10 changes: 9 additions & 1 deletion server/schedule/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (oc *OperatorController) Dispatch(region *core.RegionInfo, source string) {
oc.RemoveOperator(op)
} else if timeout {
log.Info("operator timeout", zap.Uint64("region-id", region.GetID()), zap.Reflect("operator", op))
oc.RemoveOperator(op)
oc.RemoveTimeoutOperator(op)
oc.opRecords.Put(op, pdpb.OperatorStatus_TIMEOUT)
}
}
Expand Down Expand Up @@ -238,6 +238,14 @@ func (oc *OperatorController) RemoveOperator(op *Operator) {
oc.removeOperatorLocked(op)
}

// RemoveTimeoutOperator removes a operator which is timeout from the running operators.
func (oc *OperatorController) RemoveTimeoutOperator(op *Operator) {
oc.Lock()
defer oc.Unlock()
operatorCounter.WithLabelValues(op.Desc(), "timeout").Inc()
oc.removeOperatorLocked(op)
}

// GetOperatorStatus gets the operator and its status with the specify id.
func (oc *OperatorController) GetOperatorStatus(id uint64) *OperatorWithStatus {
oc.Lock()
Expand Down