Skip to content

Commit

Permalink
[release-2.8.x] Ruler: catering for another data race in tenant config (
Browse files Browse the repository at this point in the history
#11715)

Backport 61a4205 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
https://github.com/grafana/loki/blob/5a55158cc751465846383bc758aa0c169363b292/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>
  • Loading branch information
grafanabot and Danny Kopping authored Jan 19, 2024
1 parent 47b60d6 commit 01a9c87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/ruler/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 01a9c87

Please sign in to comment.