Skip to content
Snippets Groups Projects
Commit bae89a63 authored by Goutham Veeramachaneni's avatar Goutham Veeramachaneni Committed by Tom Wilkie
Browse files

Review feedback

parent 25756b77
No related branches found
No related tags found
No related merge requests found
......@@ -81,16 +81,12 @@ func (i *Ingester) sweepInstance(instance *instance, immediate bool) {
}
func (i *Ingester) sweepStream(instance *instance, stream *stream, immediate bool) {
old := false
if len(stream.chunks) == 1 {
chunk := stream.chunks[0]
if i.cfg.MaxChunkIdle > 0 &&
time.Since(chunk.lastUpdated) > i.cfg.MaxChunkIdle {
old = true
}
if len(stream.chunks) == 0 {
return
}
if !old && len(stream.chunks) <= 1 && !immediate {
lastChunk := stream.chunks[len(stream.chunks)-1]
if time.Since(lastChunk.lastUpdated) < i.cfg.MaxChunkIdle && len(stream.chunks) <= 1 && !immediate {
return
}
......@@ -171,13 +167,11 @@ func (i *Ingester) collectChunksToFlush(instance *instance, fp model.Fingerprint
if len(stream.chunks) == 1 {
chunk := &stream.chunks[0]
if i.cfg.MaxChunkIdle > 0 &&
time.Since(chunk.lastUpdated) > i.cfg.MaxChunkIdle {
if time.Since(chunk.lastUpdated) > i.cfg.MaxChunkIdle &&
chunk.flushed.IsZero() {
chunk.closed = true
if chunk.flushed.IsZero() {
return []*chunkDesc{chunk}, stream.labels
}
return []*chunkDesc{chunk}, stream.labels
}
}
......
......@@ -97,7 +97,7 @@ func (s *testStore) checkData(t *testing.T, userIDs []string, testData map[strin
streams = append(streams, stream)
}
sort.Slice(streams, func(i, j int) bool {
return streams[i].Labels < streams[i].Labels
return streams[i].Labels < streams[j].Labels
})
require.Equal(t, testData[userID], streams)
......
......@@ -71,6 +71,10 @@ type ChunkStore interface {
// New makes a new Ingester.
func New(cfg Config, store ChunkStore) (*Ingester, error) {
if cfg.MaxChunkIdle == 0 {
cfg.MaxChunkIdle = 30 * time.Minute
}
i := &Ingester{
cfg: cfg,
instances: map[string]*instance{},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment