@@ -229,20 +229,19 @@ func defaultGroupKey(res int64, lbls labels.Labels) string {
229
229
// DefaultGrouper is the Thanos built-in grouper. It groups blocks based on downsample
230
230
// resolution and block's labels.
231
231
type DefaultGrouper struct {
232
- bkt objstore.Bucket
233
- logger log.Logger
234
- acceptMalformedIndex bool
235
- enableVerticalCompaction bool
236
- compactions * prometheus.CounterVec
237
- compactionRunsStarted * prometheus.CounterVec
238
- compactionRunsCompleted * prometheus.CounterVec
239
- compactionFailures * prometheus.CounterVec
240
- verticalCompactions * prometheus.CounterVec
241
- garbageCollectedBlocks prometheus.Counter
242
- blocksMarkedForDeletion prometheus.Counter
243
- blocksMarkedForNoCompact prometheus.Counter
244
- hashFunc metadata.HashFunc
245
- skipChunksWithOutOfOrderBlocks bool
232
+ bkt objstore.Bucket
233
+ logger log.Logger
234
+ acceptMalformedIndex bool
235
+ enableVerticalCompaction bool
236
+ compactions * prometheus.CounterVec
237
+ compactionRunsStarted * prometheus.CounterVec
238
+ compactionRunsCompleted * prometheus.CounterVec
239
+ compactionFailures * prometheus.CounterVec
240
+ verticalCompactions * prometheus.CounterVec
241
+ garbageCollectedBlocks prometheus.Counter
242
+ blocksMarkedForDeletion prometheus.Counter
243
+ blocksMarkedForNoCompact prometheus.Counter
244
+ hashFunc metadata.HashFunc
246
245
}
247
246
248
247
// NewDefaultGrouper makes a new DefaultGrouper.
@@ -256,7 +255,6 @@ func NewDefaultGrouper(
256
255
garbageCollectedBlocks prometheus.Counter ,
257
256
blocksMarkedForNoCompact prometheus.Counter ,
258
257
hashFunc metadata.HashFunc ,
259
- skipChunksWithOutOfOrderBlocks bool ,
260
258
) * DefaultGrouper {
261
259
return & DefaultGrouper {
262
260
bkt : bkt ,
@@ -283,11 +281,10 @@ func NewDefaultGrouper(
283
281
Name : "thanos_compact_group_vertical_compactions_total" ,
284
282
Help : "Total number of group compaction attempts that resulted in a new block based on overlapping blocks." ,
285
283
}, []string {"group" }),
286
- blocksMarkedForNoCompact : blocksMarkedForNoCompact ,
287
- garbageCollectedBlocks : garbageCollectedBlocks ,
288
- blocksMarkedForDeletion : blocksMarkedForDeletion ,
289
- hashFunc : hashFunc ,
290
- skipChunksWithOutOfOrderBlocks : skipChunksWithOutOfOrderBlocks ,
284
+ blocksMarkedForNoCompact : blocksMarkedForNoCompact ,
285
+ garbageCollectedBlocks : garbageCollectedBlocks ,
286
+ blocksMarkedForDeletion : blocksMarkedForDeletion ,
287
+ hashFunc : hashFunc ,
291
288
}
292
289
}
293
290
@@ -317,7 +314,6 @@ func (g *DefaultGrouper) Groups(blocks map[ulid.ULID]*metadata.Meta) (res []*Gro
317
314
g .blocksMarkedForDeletion ,
318
315
g .blocksMarkedForNoCompact ,
319
316
g .hashFunc ,
320
- g .skipChunksWithOutOfOrderBlocks ,
321
317
)
322
318
if err != nil {
323
319
return nil , errors .Wrap (err , "create compaction group" )
@@ -338,25 +334,24 @@ func (g *DefaultGrouper) Groups(blocks map[ulid.ULID]*metadata.Meta) (res []*Gro
338
334
// Group captures a set of blocks that have the same origin labels and downsampling resolution.
339
335
// Those blocks generally contain the same series and can thus efficiently be compacted.
340
336
type Group struct {
341
- logger log.Logger
342
- bkt objstore.Bucket
343
- key string
344
- labels labels.Labels
345
- resolution int64
346
- mtx sync.Mutex
347
- metasByMinTime []* metadata.Meta
348
- acceptMalformedIndex bool
349
- enableVerticalCompaction bool
350
- compactions prometheus.Counter
351
- compactionRunsStarted prometheus.Counter
352
- compactionRunsCompleted prometheus.Counter
353
- compactionFailures prometheus.Counter
354
- verticalCompactions prometheus.Counter
355
- groupGarbageCollectedBlocks prometheus.Counter
356
- blocksMarkedForDeletion prometheus.Counter
357
- blocksMarkedForNoCompact prometheus.Counter
358
- hashFunc metadata.HashFunc
359
- skipChunksWithOutofOrderBlocks bool
337
+ logger log.Logger
338
+ bkt objstore.Bucket
339
+ key string
340
+ labels labels.Labels
341
+ resolution int64
342
+ mtx sync.Mutex
343
+ metasByMinTime []* metadata.Meta
344
+ acceptMalformedIndex bool
345
+ enableVerticalCompaction bool
346
+ compactions prometheus.Counter
347
+ compactionRunsStarted prometheus.Counter
348
+ compactionRunsCompleted prometheus.Counter
349
+ compactionFailures prometheus.Counter
350
+ verticalCompactions prometheus.Counter
351
+ groupGarbageCollectedBlocks prometheus.Counter
352
+ blocksMarkedForDeletion prometheus.Counter
353
+ blocksMarkedForNoCompact prometheus.Counter
354
+ hashFunc metadata.HashFunc
360
355
}
361
356
362
357
// NewGroup returns a new compaction group.
@@ -377,29 +372,27 @@ func NewGroup(
377
372
blocksMarkedForDeletion prometheus.Counter ,
378
373
blockMakredForNoCopmact prometheus.Counter ,
379
374
hashFunc metadata.HashFunc ,
380
- skipChunksWithOutOfOrderChunks bool ,
381
375
) (* Group , error ) {
382
376
if logger == nil {
383
377
logger = log .NewNopLogger ()
384
378
}
385
379
g := & Group {
386
- logger : logger ,
387
- bkt : bkt ,
388
- key : key ,
389
- labels : lset ,
390
- resolution : resolution ,
391
- acceptMalformedIndex : acceptMalformedIndex ,
392
- enableVerticalCompaction : enableVerticalCompaction ,
393
- compactions : compactions ,
394
- compactionRunsStarted : compactionRunsStarted ,
395
- compactionRunsCompleted : compactionRunsCompleted ,
396
- compactionFailures : compactionFailures ,
397
- verticalCompactions : verticalCompactions ,
398
- groupGarbageCollectedBlocks : groupGarbageCollectedBlocks ,
399
- blocksMarkedForDeletion : blocksMarkedForDeletion ,
400
- blocksMarkedForNoCompact : blockMakredForNoCopmact ,
401
- hashFunc : hashFunc ,
402
- skipChunksWithOutofOrderBlocks : skipChunksWithOutOfOrderChunks ,
380
+ logger : logger ,
381
+ bkt : bkt ,
382
+ key : key ,
383
+ labels : lset ,
384
+ resolution : resolution ,
385
+ acceptMalformedIndex : acceptMalformedIndex ,
386
+ enableVerticalCompaction : enableVerticalCompaction ,
387
+ compactions : compactions ,
388
+ compactionRunsStarted : compactionRunsStarted ,
389
+ compactionRunsCompleted : compactionRunsCompleted ,
390
+ compactionFailures : compactionFailures ,
391
+ verticalCompactions : verticalCompactions ,
392
+ groupGarbageCollectedBlocks : groupGarbageCollectedBlocks ,
393
+ blocksMarkedForDeletion : blocksMarkedForDeletion ,
394
+ blocksMarkedForNoCompact : blockMakredForNoCopmact ,
395
+ hashFunc : hashFunc ,
403
396
}
404
397
return g , nil
405
398
}
@@ -783,7 +776,7 @@ func (cg *Group) compact(ctx context.Context, dir string, planner Planner, comp
783
776
return false , ulid.ULID {}, halt (errors .Wrapf (err , "block with not healthy index found %s; Compaction level %v; Labels: %v" , bdir , meta .Compaction .Level , meta .Thanos .Labels ))
784
777
}
785
778
786
- if err := stats .OutOfOrderChunksErr (); cg . skipChunksWithOutofOrderBlocks && err != nil {
779
+ if err := stats .OutOfOrderChunksErr (); err != nil {
787
780
return false , ulid.ULID {}, outOfOrderChunkError (errors .Wrapf (err , "blocks with out-of-order chunks are dropped from compaction: %s" , bdir ), meta .ULID )
788
781
}
789
782
@@ -890,14 +883,15 @@ func (cg *Group) deleteBlock(id ulid.ULID, bdir string) error {
890
883
891
884
// BucketCompactor compacts blocks in a bucket.
892
885
type BucketCompactor struct {
893
- logger log.Logger
894
- sy * Syncer
895
- grouper Grouper
896
- comp Compactor
897
- planner Planner
898
- compactDir string
899
- bkt objstore.Bucket
900
- concurrency int
886
+ logger log.Logger
887
+ sy * Syncer
888
+ grouper Grouper
889
+ comp Compactor
890
+ planner Planner
891
+ compactDir string
892
+ bkt objstore.Bucket
893
+ concurrency int
894
+ skipBlocksWithOutOfOrderChunks bool
901
895
}
902
896
903
897
// NewBucketCompactor creates a new bucket compactor.
@@ -910,19 +904,21 @@ func NewBucketCompactor(
910
904
compactDir string ,
911
905
bkt objstore.Bucket ,
912
906
concurrency int ,
907
+ skipBlocksWithOutOfOrderChunks bool ,
913
908
) (* BucketCompactor , error ) {
914
909
if concurrency <= 0 {
915
910
return nil , errors .Errorf ("invalid concurrency level (%d), concurrency level must be > 0" , concurrency )
916
911
}
917
912
return & BucketCompactor {
918
- logger : logger ,
919
- sy : sy ,
920
- grouper : grouper ,
921
- planner : planner ,
922
- comp : comp ,
923
- compactDir : compactDir ,
924
- bkt : bkt ,
925
- concurrency : concurrency ,
913
+ logger : logger ,
914
+ sy : sy ,
915
+ grouper : grouper ,
916
+ planner : planner ,
917
+ comp : comp ,
918
+ compactDir : compactDir ,
919
+ bkt : bkt ,
920
+ concurrency : concurrency ,
921
+ skipBlocksWithOutOfOrderChunks : skipBlocksWithOutOfOrderChunks ,
926
922
}, nil
927
923
}
928
924
@@ -977,8 +973,10 @@ func (c *BucketCompactor) Compact(ctx context.Context) (rerr error) {
977
973
continue
978
974
}
979
975
}
980
- // if block has out of order chunk, mark the block for no compaction and continue.
981
- if IsOutOfOrderChunkError (err ) {
976
+ // If block has out of order chunk and it has been configured to skip it,
977
+ // then we can mark the block for no compaction so that the next compaction run
978
+ // will skip it.
979
+ if IsOutOfOrderChunkError (err ) && c .skipBlocksWithOutOfOrderChunks {
982
980
if err := block .MarkForNoCompact (
983
981
ctx ,
984
982
c .logger ,
0 commit comments