diff --git a/CHANGELOG.md b/CHANGELOG.md index 831aca5b0c4..e94db6ff9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### Bugfixes - [#2282](https://github.com/influxdb/influxdb/pull/2282): Use "value" as field name for OpenTSDB input. +## Features +- [#2276](https://github.com/influxdb/influxdb/pull/2276): Broker topic truncation. + ## v0.9.0-rc24 [2015-04-13] ### Bugfixes diff --git a/cmd/influxd/config.go b/cmd/influxd/config.go index 0fc14dfc7ff..e1ace8a5c62 100644 --- a/cmd/influxd/config.go +++ b/cmd/influxd/config.go @@ -68,7 +68,7 @@ const ( DefaultRetentionCheckEnabled = true // DefaultRetentionCheckPeriod is the period of time between retention policy checks are run - DefaultRetentionCheckPeriod = 30 * time.Minute + DefaultRetentionCheckPeriod = 10 * time.Minute // DefaultRecomputePreviousN is ??? DefaultContinuousQueryRecomputePreviousN = 2 diff --git a/messaging/broker.go b/messaging/broker.go index 063b6db192c..e9fb14cb8f2 100644 --- a/messaging/broker.go +++ b/messaging/broker.go @@ -190,9 +190,14 @@ func (b *Broker) Open(path string) error { go func() { defer b.wg.Done() tick := time.NewTicker(b.TruncationInterval) + defer tick.Stop() for { - <-tick.C - b.TruncateTopics() + select { + case <-tick.C: + b.TruncateTopics() + case <-b.done: + return + } } }() @@ -274,7 +279,7 @@ func (b *Broker) closeTopics() { // truncateTopics forces topics to truncate such that they are equal to // or less than the requested size, if possible. -func (b *Broker) TruncateTopics() error { +func (b *Broker) TruncateTopics() { for _, t := range b.topics { if n, err := t.Truncate(b.MaxTopicSize); err != nil { b.Logger.Printf("error truncating topic %s: %s", t.Path(), err.Error()) @@ -282,7 +287,7 @@ func (b *Broker) TruncateTopics() error { b.Logger.Printf("topic %s, %d bytes deleted", t.Path(), n) } } - return nil + return } // SetMaxIndex sets the highest index applied by the broker.