-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Fix concurrency issues with metrics #3401
Conversation
@@ -89,28 +91,41 @@ func (m *Metrics) allMetrics() []prometheus.Metric { | |||
} | |||
|
|||
func (m *Metrics) WorkflowAdded(key string, phase v1alpha1.NodePhase) { | |||
if m.workflows[key] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you simplify to use sync.Mutex
for and defer
. I think the benefit of simpler code would outweight the reduced efficiency.
workflow/metrics/metrics.go
Outdated
@@ -34,6 +35,7 @@ type metric struct { | |||
} | |||
|
|||
type Metrics struct { | |||
workflowsMutex sync.RWMutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to comment and say what fields this is used to lock on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please backport to v2.9?
Back-ported to 2.9.2 |
Fixes: #3391