Skip to content

Commit ac53892

Browse files
bborehampracucci
authored andcommitted
Pass the correct flush reason to closeHead()
Pass the reason from `shouldFlushChunk()` to `closeHead()`; sending `reasonImmediate` was a bug. We don't need to check `len(chunks)` is non-zero, since that would return `noFlush` from `shouldFlushSeries()`. Signed-off-by: Bryan Boreham <bryan@weave.works>
1 parent 7615b85 commit ac53892

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/ingester/flush.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,14 @@ func (i *Ingester) flushUserSeries(flushQueueIndex int, userID string, fp model.
290290
return nil
291291
}
292292

293-
// Assume we're going to flush everything, and maybe don't flush the head chunk if it doesn't need it.
293+
// shouldFlushSeries() has told us we have at least one chunk
294294
chunks := series.chunkDescs
295-
if immediate || (len(chunks) > 0 && i.shouldFlushChunk(series.head(), fp, series.isStale()) != noFlush) {
295+
if immediate {
296296
series.closeHead(reasonImmediate)
297+
} else if chunkReason := i.shouldFlushChunk(series.head(), fp, series.isStale()); chunkReason != noFlush {
298+
series.closeHead(chunkReason)
297299
} else {
300+
// The head chunk doesn't need flushing; step back by one.
298301
chunks = chunks[:len(chunks)-1]
299302
}
300303

0 commit comments

Comments
 (0)