From d01dd635cdcea88e967388dfd818e758cb0b5ac5 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Tue, 18 Apr 2023 11:03:12 +0800 Subject: [PATCH] oomtest: fix data race at the oomCapture Signed-off-by: Weizhen Wang --- executor/oomtest/oom_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/executor/oomtest/oom_test.go b/executor/oomtest/oom_test.go index cd8490e189cad..2229acd5f5caa 100644 --- a/executor/oomtest/oom_test.go +++ b/executor/oomtest/oom_test.go @@ -228,6 +228,8 @@ func (h *oomCapture) AddMessageFilter(vals ...string) { } func (h *oomCapture) ClearMessageFilter() { + h.mu.Lock() + defer h.mu.Unlock() h.messageFilter.Clear() } @@ -255,7 +257,9 @@ func (h *oomCapture) Write(entry zapcore.Entry, fields []zapcore.Field) error { if end == -1 { panic("end not found") } + h.mu.Lock() h.tracker = str[begin+len("8001]") : end] + h.mu.Unlock() return nil } // They are just common background task and not related to the oom.