[release-2.9.x] Ruler: catering for another data race in tenant config (#11714)

Backport 61a4205313 from #11612

---

Expands on #11601

**What this PR does / why we need it**:
Turns out the previous tests didn't expose all possible causes for data
races (another one occurs at
5a55158cc7/pkg/ruler/registry.go (L204)).
Moving the mutex to the calling function adds more safety.

**Which issue(s) this PR fixes**:
Fixes #11569

Co-authored-by: Danny Kopping <danny.kopping@grafana.com>
pull/11760/head
Grot (@grafanabot) 1 year ago committed by GitHub
parent c28f12be8e
commit 94f97fb52d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      pkg/ruler/registry.go

@ -179,6 +179,9 @@ func (r *walRegistry) stop() {
}
func (r *walRegistry) getTenantConfig(tenant string) (instance.Config, error) {
r.overridesMu.Lock()
defer r.overridesMu.Unlock()
conf, err := r.config.WAL.Clone()
if err != nil {
return instance.Config{}, err
@ -225,9 +228,6 @@ func (r *walRegistry) getTenantConfig(tenant string) (instance.Config, error) {
}
func (r *walRegistry) getTenantRemoteWriteConfig(tenant string, base RemoteWriteConfig) (*RemoteWriteConfig, error) {
r.overridesMu.Lock()
defer r.overridesMu.Unlock()
overrides, err := base.Clone()
if err != nil {
return nil, fmt.Errorf("error generating tenant remote-write config: %w", err)

Loading…
Cancel
Save