From 092c07a18c89fef779018ccd18309e63d75bb565 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 7 Jan 2021 15:38:37 +0530 Subject: [PATCH] MM-31370: Fix racy TestClusterShutdownRace (#16562) * MM-31370: Fix racy TestClusterShutdownRace This race wasn't specific to this test, but somehow got triggered by it. This was a critical race because the PluginsLock is widely used throughout the codebase to gate access to the PluginsEnvironment. However, a config listener can often run in its own goroutine leading to a wide variety of races. https://mattermost.atlassian.net/browse/MM-31370 ```release-note NONE ``` * incorporate review comments Co-authored-by: Mattermod --- app/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/server.go b/app/server.go index 67fba7098a..ee3459a6dd 100644 --- a/app/server.go +++ b/app/server.go @@ -500,7 +500,9 @@ func NewServer(options ...Option) (*Server, error) { pluginsEnvironment.InitPluginHealthCheckJob(*s.Config().PluginSettings.Enable && *s.Config().PluginSettings.EnableHealthCheck) } s.AddConfigListener(func(_, c *model.Config) { + s.PluginsLock.RLock() pluginsEnvironment := s.PluginsEnvironment + s.PluginsLock.RUnlock() if pluginsEnvironment != nil { pluginsEnvironment.InitPluginHealthCheckJob(*s.Config().PluginSettings.Enable && *c.PluginSettings.EnableHealthCheck) }