Skip to content

Commit

Permalink
allow 0 as a valid truncation timestamp (#440)
Browse files Browse the repository at this point in the history
A remote_write timestamp of 0 preventing truncations from occurring.
Ignoring 0s was an unnecessary safety measure, and only caused problems
when considering the min/max WAL sample lifetime.

Closes #409.
  • Loading branch information
rfratto authored Mar 1, 2021
1 parent 0facc71 commit 04ba036
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ can be found at [#317](https://github.com/grafana/agent/issues/317).
- [BUGFIX] Native Darwin arm64 builds will no longer crash when writing metrics
to the WAL. (@rfratto)

- [BUGFIX] Remote write endpoints that never function across the lifetime of the
Agent will no longer prevent the WAL from being truncated. (@rfratto)

# v0.13.0 (2021-02-25)

The primary branch name has changed from `master` to `main`. You may have to
Expand Down
8 changes: 3 additions & 5 deletions pkg/prom/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,10 @@ func (i *Instance) truncateLoop(ctx context.Context, wal walStorage, cfg *Config
//
// Subtracting a duration from ts will delay when it will be considered
// inactive and scheduled for deletion.
ts := i.getRemoteWriteTimestamp()
if ts == 0 {
level.Debug(i.logger).Log("msg", "can't truncate the WAL yet")
continue
ts := i.getRemoteWriteTimestamp() - i.cfg.MinWALTime.Milliseconds()
if ts < 0 {
ts = 0
}
ts -= i.cfg.MinWALTime.Milliseconds()

// Network issues can prevent the result of getRemoteWriteTimestamp from
// changing. We don't want data in the WAL to grow forever, so we set a cap
Expand Down

0 comments on commit 04ba036

Please sign in to comment.