mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
[CHORE] adding startup min retention time
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
This commit is contained in:
parent
5b5fee08af
commit
9d307e8417
|
@ -1826,6 +1826,7 @@ func (opts tsdbOptions) ToTSDBOptions() tsdb.Options {
|
||||||
EnableDelayedCompaction: opts.EnableDelayedCompaction,
|
EnableDelayedCompaction: opts.EnableDelayedCompaction,
|
||||||
CompactionDelayMaxPercent: opts.CompactionDelayMaxPercent,
|
CompactionDelayMaxPercent: opts.CompactionDelayMaxPercent,
|
||||||
EnableOverlappingCompaction: opts.EnableOverlappingCompaction,
|
EnableOverlappingCompaction: opts.EnableOverlappingCompaction,
|
||||||
|
StartupMinRetentionTime: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
tsdb/db.go
17
tsdb/db.go
|
@ -92,6 +92,7 @@ func DefaultOptions() *Options {
|
||||||
CompactionDelayMaxPercent: DefaultCompactionDelayMaxPercent,
|
CompactionDelayMaxPercent: DefaultCompactionDelayMaxPercent,
|
||||||
CompactionDelay: time.Duration(0),
|
CompactionDelay: time.Duration(0),
|
||||||
PostingsDecoderFactory: DefaultPostingsDecoderFactory,
|
PostingsDecoderFactory: DefaultPostingsDecoderFactory,
|
||||||
|
StartupMinRetentionTime: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +225,10 @@ type Options struct {
|
||||||
// PostingsDecoderFactory allows users to customize postings decoders based on BlockMeta.
|
// PostingsDecoderFactory allows users to customize postings decoders based on BlockMeta.
|
||||||
// By default, DefaultPostingsDecoderFactory will be used to create raw posting decoder.
|
// By default, DefaultPostingsDecoderFactory will be used to create raw posting decoder.
|
||||||
PostingsDecoderFactory PostingsDecoderFactory
|
PostingsDecoderFactory PostingsDecoderFactory
|
||||||
|
|
||||||
|
// StartupMinRetentionTime is the used to delete blocks and ignore samples from the WAL
|
||||||
|
// during the startup of the TSDB.
|
||||||
|
StartupMinRetentionTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewCompactorFunc func(ctx context.Context, r prometheus.Registerer, l *slog.Logger, ranges []int64, pool chunkenc.Pool, opts *Options) (Compactor, error)
|
type NewCompactorFunc func(ctx context.Context, r prometheus.Registerer, l *slog.Logger, ranges []int64, pool chunkenc.Pool, opts *Options) (Compactor, error)
|
||||||
|
@ -814,6 +819,9 @@ func validateOpts(opts *Options, rngs []int64) (*Options, []int64) {
|
||||||
if opts.OutOfOrderTimeWindow < 0 {
|
if opts.OutOfOrderTimeWindow < 0 {
|
||||||
opts.OutOfOrderTimeWindow = 0
|
opts.OutOfOrderTimeWindow = 0
|
||||||
}
|
}
|
||||||
|
if opts.StartupMinRetentionTime.IsZero() {
|
||||||
|
opts.StartupMinRetentionTime = time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
if len(rngs) == 0 {
|
if len(rngs) == 0 {
|
||||||
// Start with smallest block duration and create exponential buckets until the exceed the
|
// Start with smallest block duration and create exponential buckets until the exceed the
|
||||||
|
@ -885,10 +893,6 @@ func open(dir string, l *slog.Logger, r prometheus.Registerer, opts *Options, rn
|
||||||
returnedErr = errs.Err()
|
returnedErr = errs.Err()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if db.blocksToDelete == nil {
|
|
||||||
db.blocksToDelete = DefaultBlocksToDelete(db)
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
db.locker, err = tsdbutil.NewDirLocker(dir, "tsdb", db.logger, r)
|
db.locker, err = tsdbutil.NewDirLocker(dir, "tsdb", db.logger, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -952,6 +956,11 @@ func open(dir string, l *slog.Logger, r prometheus.Registerer, opts *Options, rn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if db.blocksToDelete == nil {
|
||||||
|
db.blocksToDelete = DefaultBlocksToDelete(db)
|
||||||
|
}
|
||||||
|
|
||||||
db.oooWasEnabled.Store(opts.OutOfOrderTimeWindow > 0)
|
db.oooWasEnabled.Store(opts.OutOfOrderTimeWindow > 0)
|
||||||
headOpts := DefaultHeadOptions()
|
headOpts := DefaultHeadOptions()
|
||||||
headOpts.ChunkRange = rngs[0]
|
headOpts.ChunkRange = rngs[0]
|
||||||
|
|
Loading…
Reference in a new issue