From f5f78f9bdcdfde8a51f0e1e46839b945834407dd Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 13 Apr 2015 20:03:07 -0700 Subject: [PATCH] Update CHANGELOG --- CHANGELOG.md | 5 +++++ messaging/broker.go | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b10fb52a8..d3ab6c4b8b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.9.0-rc24 [unreleased] + +## Features +- [#2276](https://github.com/influxdb/influxdb/pull/2276): Basic size-based broker truncation. + ## v0.9.0-rc24 [2015-04-13] ### Bugfixes diff --git a/messaging/broker.go b/messaging/broker.go index d891293ba9b..56fcdf83900 100644 --- a/messaging/broker.go +++ b/messaging/broker.go @@ -189,9 +189,14 @@ func (b *Broker) Open(path string) error { go func() { b.wg.Add(1) tick := time.NewTicker(b.TruncationInterval) + defer tick.Stop() for { - <-tick.C - b.TruncateTopics() + select { + case <-tick.C: + b.TruncateTopics() + case <-b.done: + return + } } }() @@ -273,7 +278,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()) @@ -281,7 +286,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.