From 2750025201b073dbdeb807680419c891aa3bc7d9 Mon Sep 17 00:00:00 2001 From: Romain Gaillard Date: Tue, 29 Oct 2024 09:42:47 +0100 Subject: [PATCH] Lock mutex for reading while processing logs (#1931) --- internal/component/loki/secretfilter/secretfilter.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/component/loki/secretfilter/secretfilter.go b/internal/component/loki/secretfilter/secretfilter.go index 5e34864360..46d0886fa6 100644 --- a/internal/component/loki/secretfilter/secretfilter.go +++ b/internal/component/loki/secretfilter/secretfilter.go @@ -145,6 +145,7 @@ func (c *Component) Run(ctx context.Context) error { case <-ctx.Done(): return nil case entry := <-c.receiver.Chan(): + c.mut.RLock() // Start processing the log entry to redact secrets newEntry := c.processEntry(entry) if c.debugDataPublisher.IsActive(componentID) { @@ -154,10 +155,12 @@ func (c *Component) Run(ctx context.Context) error { for _, f := range c.fanout { select { case <-ctx.Done(): + c.mut.RUnlock() return nil case f.Chan() <- newEntry: } } + c.mut.RUnlock() } } }