Skip to content

Commit

Permalink
close WALs after calculating cardinality/sample stats (#507)
Browse files Browse the repository at this point in the history
* close WALs after calculating cardinality/sample stats

* changelog
  • Loading branch information
rfratto authored Apr 1, 2021
1 parent 07b9f5f commit 182b962
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ cross-compilation issue, but will return in v0.13.0.

- [BUGFIX] Bring back FreeBSD support. (@rfratto)

- [BUGFIX] agentctl will no longer leak WAL resources when retrieving WAL stats. (@rfratto)

- [CHANGE] The Grafana Cloud Agent has been renamed to the Grafana Agent.
(@rfratto)

Expand Down
1 change: 1 addition & 0 deletions pkg/agentctl/cardinality.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func FindCardinality(walDir string, job string, instance string) ([]Cardinality,
if err != nil {
return nil, err
}
defer w.Close()

cardinality := map[string]int{}

Expand Down
1 change: 1 addition & 0 deletions pkg/agentctl/samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func FindSamples(walDir string, selectorStr string) ([]*SampleStats, error) {
if err != nil {
return nil, err
}
defer w.Close()

selector, err := parser.ParseMetricSelector(selectorStr)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/prom/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ func (i *Instance) Run(ctx context.Context) error {
}
}

// Closing the storage closes both the WAL storage and remote wrte
// storage.
level.Info(i.logger).Log("msg", "closing storage...")
if err := i.storage.Close(); err != nil {
level.Error(i.logger).Log("msg", "error stopping storage", "err", err)
Expand Down

0 comments on commit 182b962

Please sign in to comment.