Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add a new segment every HH purge check #4389

Merged
merged 2 commits into from
Oct 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#4291](https://github.com/influxdb/influxdb/pull/4291): Added ALTER DATABASE RENAME. Thanks @linearb

### Bugfixes
- [#4389](https://github.com/influxdb/influxdb/pull/4389): Don't add a new segment file on each hinted-handoff purge cycle.
- [#4166](https://github.com/influxdb/influxdb/pull/4166): Fix parser error on invalid SHOW
- [#3457](https://github.com/influxdb/influxdb/issues/3457): [0.9.3] cannot select field names with prefix + "." that match the measurement name
- [#4225](https://github.com/influxdb/influxdb/pull/4225): Always display diags in name-sorted order
Expand Down
15 changes: 12 additions & 3 deletions services/hh/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ func (l *queue) PurgeOlderThan(when time.Time) error {
l.mu.Lock()
defer l.mu.Unlock()

// Add a new empty segment so old ones can be reclaimed
if _, err := l.addSegment(); err != nil {
return err
if len(l.segments) == 0 {
return nil
}

cutoff := when.Truncate(time.Second)
Expand All @@ -188,6 +187,16 @@ func (l *queue) PurgeOlderThan(when time.Time) error {
if mod.After(cutoff) || mod.Equal(cutoff) {
return nil
}

// If this is the last segment, first append a new one allowing
// trimming to proceed.
if len(l.segments) == 1 {
_, err := l.addSegment()
if err != nil {
return err
}
}

if err := l.trimHead(); err != nil {
return err
}
Expand Down