From 4a93b625f857ab582e87c17029ee893612ca6cfe Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sun, 15 May 2022 22:05:45 +0800 Subject: [PATCH] Fix the potential data race with RWLock Signed-off-by: kerthcet --- pkg/pipelinerunmetrics/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pipelinerunmetrics/metrics.go b/pkg/pipelinerunmetrics/metrics.go index 6daa5efcf0e..d5920f43478 100644 --- a/pkg/pipelinerunmetrics/metrics.go +++ b/pkg/pipelinerunmetrics/metrics.go @@ -255,7 +255,7 @@ func (r *Recorder) DurationAndCount(pr *v1beta1.PipelineRun) error { // returns an error if its failed to log the metrics func (r *Recorder) RunningPipelineRuns(lister listers.PipelineRunLister) error { r.mutex.Lock() - r.mutex.Unlock() + defer r.mutex.Unlock() if !r.initialized { return errors.New("ignoring the metrics recording, failed to initialize the metrics recorder")