mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
tsdb/main: wire "EnableOverlappingCompaction" to tsdb.Options (#13398)
This added the https://github.com/prometheus/prometheus/pull/13393 "EnableOverlappingCompaction" parameter to the compactor code but not to the tsdb.Options. I forgot about that. Add it to `tsdb.Options` too and set it to `true` in Prometheus. Copy/paste the description from https://github.com/prometheus/prometheus/pull/13393#issuecomment-1891787986 Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
This commit is contained in:
parent
90000a2ef2
commit
b695e069b8
|
@ -1646,6 +1646,7 @@ func (opts tsdbOptions) ToTSDBOptions() tsdb.Options {
|
||||||
EnableMemorySnapshotOnShutdown: opts.EnableMemorySnapshotOnShutdown,
|
EnableMemorySnapshotOnShutdown: opts.EnableMemorySnapshotOnShutdown,
|
||||||
EnableNativeHistograms: opts.EnableNativeHistograms,
|
EnableNativeHistograms: opts.EnableNativeHistograms,
|
||||||
OutOfOrderTimeWindow: opts.OutOfOrderTimeWindow,
|
OutOfOrderTimeWindow: opts.OutOfOrderTimeWindow,
|
||||||
|
EnableOverlappingCompaction: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
tsdb/db.go
40
tsdb/db.go
|
@ -70,19 +70,20 @@ var ErrNotReady = errors.New("TSDB not ready")
|
||||||
// millisecond precision timestamps.
|
// millisecond precision timestamps.
|
||||||
func DefaultOptions() *Options {
|
func DefaultOptions() *Options {
|
||||||
return &Options{
|
return &Options{
|
||||||
WALSegmentSize: wlog.DefaultSegmentSize,
|
WALSegmentSize: wlog.DefaultSegmentSize,
|
||||||
MaxBlockChunkSegmentSize: chunks.DefaultChunkSegmentSize,
|
MaxBlockChunkSegmentSize: chunks.DefaultChunkSegmentSize,
|
||||||
RetentionDuration: int64(15 * 24 * time.Hour / time.Millisecond),
|
RetentionDuration: int64(15 * 24 * time.Hour / time.Millisecond),
|
||||||
MinBlockDuration: DefaultBlockDuration,
|
MinBlockDuration: DefaultBlockDuration,
|
||||||
MaxBlockDuration: DefaultBlockDuration,
|
MaxBlockDuration: DefaultBlockDuration,
|
||||||
NoLockfile: false,
|
NoLockfile: false,
|
||||||
SamplesPerChunk: DefaultSamplesPerChunk,
|
SamplesPerChunk: DefaultSamplesPerChunk,
|
||||||
WALCompression: wlog.CompressionNone,
|
WALCompression: wlog.CompressionNone,
|
||||||
StripeSize: DefaultStripeSize,
|
StripeSize: DefaultStripeSize,
|
||||||
HeadChunksWriteBufferSize: chunks.DefaultWriteBufferSize,
|
HeadChunksWriteBufferSize: chunks.DefaultWriteBufferSize,
|
||||||
IsolationDisabled: defaultIsolationDisabled,
|
IsolationDisabled: defaultIsolationDisabled,
|
||||||
HeadChunksWriteQueueSize: chunks.DefaultWriteQueueSize,
|
HeadChunksWriteQueueSize: chunks.DefaultWriteQueueSize,
|
||||||
OutOfOrderCapMax: DefaultOutOfOrderCapMax,
|
OutOfOrderCapMax: DefaultOutOfOrderCapMax,
|
||||||
|
EnableOverlappingCompaction: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +178,14 @@ type Options struct {
|
||||||
// OutOfOrderCapMax is maximum capacity for OOO chunks (in samples).
|
// OutOfOrderCapMax is maximum capacity for OOO chunks (in samples).
|
||||||
// If it is <=0, the default value is assumed.
|
// If it is <=0, the default value is assumed.
|
||||||
OutOfOrderCapMax int64
|
OutOfOrderCapMax int64
|
||||||
|
|
||||||
|
// Compaction of overlapping blocks are allowed if EnableOverlappingCompaction is true.
|
||||||
|
// This is an optional flag for overlapping blocks.
|
||||||
|
// The reason why this flag exists is because there are various users of the TSDB
|
||||||
|
// that do not want vertical compaction happening on ingest time. Instead,
|
||||||
|
// they'd rather keep overlapping blocks and let another component do the overlapping compaction later.
|
||||||
|
// For Prometheus, this will always be true.
|
||||||
|
EnableOverlappingCompaction bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlocksToDeleteFunc func(blocks []*Block) map[ulid.ULID]struct{}
|
type BlocksToDeleteFunc func(blocks []*Block) map[ulid.ULID]struct{}
|
||||||
|
@ -816,7 +825,10 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
db.compactor, err = NewLeveledCompactorWithChunkSize(ctx, r, l, rngs, db.chunkPool, opts.MaxBlockChunkSegmentSize, nil)
|
db.compactor, err = NewLeveledCompactorWithOptions(ctx, r, l, rngs, db.chunkPool, LeveledCompactorOptions{
|
||||||
|
MaxBlockChunkSegmentSize: opts.MaxBlockChunkSegmentSize,
|
||||||
|
EnableOverlappingCompaction: opts.EnableOverlappingCompaction,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
cancel()
|
||||||
return nil, fmt.Errorf("create leveled compactor: %w", err)
|
return nil, fmt.Errorf("create leveled compactor: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue