@@ -360,7 +360,7 @@ func (u *userTSDB) casState(from, to tsdbState) bool {
360
360
}
361
361
362
362
// compactHead compacts the Head block at specified block durations avoiding a single huge block.
363
- func (u * userTSDB ) compactHead (blockDuration int64 ) error {
363
+ func (u * userTSDB ) compactHead (ctx context. Context , blockDuration int64 ) error {
364
364
if ! u .casState (active , forceCompacting ) {
365
365
return errors .New ("TSDB head cannot be compacted because it is not in active state (possibly being closed or blocks shipping in progress)" )
366
366
}
@@ -388,7 +388,10 @@ func (u *userTSDB) compactHead(blockDuration int64) error {
388
388
minTime , maxTime = h .MinTime (), h .MaxTime ()
389
389
}
390
390
391
- return u .db .CompactHead (tsdb .NewRangeHead (h , minTime , maxTime ))
391
+ if err := u .db .CompactHead (tsdb .NewRangeHead (h , minTime , maxTime )); err != nil {
392
+ return err
393
+ }
394
+ return u .db .CompactOOOHead (ctx )
392
395
}
393
396
394
397
// PreCreation implements SeriesLifecycleCallback interface.
@@ -2536,12 +2539,12 @@ func (i *Ingester) compactBlocks(ctx context.Context, force bool, allowed *util.
2536
2539
switch {
2537
2540
case force :
2538
2541
reason = "forced"
2539
- err = userDB .compactHead (i .cfg .BlocksStorageConfig .TSDB .BlockRanges [0 ].Milliseconds ())
2542
+ err = userDB .compactHead (ctx , i .cfg .BlocksStorageConfig .TSDB .BlockRanges [0 ].Milliseconds ())
2540
2543
2541
2544
case i .TSDBState .compactionIdleTimeout > 0 && userDB .isIdle (time .Now (), i .TSDBState .compactionIdleTimeout ):
2542
2545
reason = "idle"
2543
2546
level .Info (logutil .WithContext (ctx , i .logger )).Log ("msg" , "TSDB is idle, forcing compaction" , "user" , userID )
2544
- err = userDB .compactHead (i .cfg .BlocksStorageConfig .TSDB .BlockRanges [0 ].Milliseconds ())
2547
+ err = userDB .compactHead (ctx , i .cfg .BlocksStorageConfig .TSDB .BlockRanges [0 ].Milliseconds ())
2545
2548
2546
2549
default :
2547
2550
reason = "regular"
0 commit comments