Skip to content

Commit

Permalink
Ruler: catering for another data race in tenant config (#11612)
Browse files Browse the repository at this point in the history
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

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
(cherry picked from commit 61a4205)
  • Loading branch information
Danny Kopping authored and grafana-delivery-bot[bot] committed Jan 19, 2024
1 parent c28f12b commit 0cf3db0
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 0cf3db0

Please sign in to comment.