Merge pull request #4389 from influxdb/hh_extra_segs

Don't add a new segment every HH purge check
pull/4393/head
Philip O'Toole 2015-10-09 14:38:04 -07:00
commit bb2ce2f7fb
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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)
@ -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
}