Skip to content

Commit

Permalink
Add blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples
Browse files Browse the repository at this point in the history
…flag (#10035)

* Add blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples flag  (#9981)

* Add blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples flag

Signed-off-by: Ganesh Vernekar <[email protected]>

* Update pkg/storage/tsdb/config.go

Co-authored-by: chencs <[email protected]>

* Make flag experimental

Signed-off-by: Ganesh Vernekar <[email protected]>

---------

Signed-off-by: Ganesh Vernekar <[email protected]>
Co-authored-by: chencs <[email protected]>

* CHANGELOG

Signed-off-by: Ganesh Vernekar <[email protected]>

* CHANGELOG

Signed-off-by: Ganesh Vernekar <[email protected]>

---------

Signed-off-by: Ganesh Vernekar <[email protected]>
Co-authored-by: chencs <[email protected]>
(cherry picked from commit 832d02b)
  • Loading branch information
codesome committed Dec 2, 2024
1 parent 91a568c commit f8462ee
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
* [ENHANCEMENT] Distributor: Initialize ha_tracker cache before ha_tracker and distributor reach running state and begin serving writes. #9826 #9976
* [ENHANCEMENT] Ingester: `-ingest-storage.kafka.max-buffered-bytes` to limit the memory for buffered records when using concurrent fetching. #9892
* [ENHANCEMENT] Querier: improve performance and memory consumption of queries that select many series. #9914
* [ENHANCEMENT] Ruler: Support OAuth2 and proxies in Alertmanager client #9945
* [ENHANCEMENT] Ingester: Add `-blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples` to build 24h blocks for out-of-order data belonging to the previous days instead of building smaller 2h blocks. This reduces pressure on compactors and ingesters when the out-of-order samples span multiple days in the past. #9844 #10033 #10035
* [ENHANCEMENT] Distributor: allow a different limit for info series (series ending in `_info`) label count, via `-validation.max-label-names-per-info-series`. #10028
* [BUGFIX] Fix issue where functions such as `rate()` over native histograms could return incorrect values if a float stale marker was present in the selected range. #9508
* [BUGFIX] Fix issue where negation of native histograms (eg. `-some_native_histogram_series`) did nothing. #9508
* [BUGFIX] Fix issue where `metric might not be a counter, name does not end in _total/_sum/_count/_bucket` annotation would be emitted even if `rate` or `increase` did not have enough samples to compute a result. #9508
Expand Down
11 changes: 11 additions & 0 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -10210,6 +10210,17 @@
"fieldType": "int",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "bigger_out_of_order_blocks_for_old_samples",
"required": false,
"desc": "When enabled, ingester produces 24h blocks for out-of-order data that is before the current day, instead of the usual 2h blocks.",
"fieldValue": null,
"fieldDefaultValue": false,
"fieldFlag": "blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples",
"fieldType": "boolean",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "series_hash_cache_max_size_bytes",
Expand Down
2 changes: 2 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ Usage of ./cmd/mimir/mimir:
OpenStack Swift user ID.
-blocks-storage.swift.username string
OpenStack Swift username.
-blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples
[experimental] When enabled, ingester produces 24h blocks for out-of-order data that is before the current day, instead of the usual 2h blocks.
-blocks-storage.tsdb.block-postings-for-matchers-cache-force
[experimental] Force the cache to be used for postings for matchers in compacted blocks, even if it's not a concurrent (query-sharding) call.
-blocks-storage.tsdb.block-postings-for-matchers-cache-max-bytes int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4400,6 +4400,11 @@ tsdb:
# CLI flag: -blocks-storage.tsdb.head-chunks-write-queue-size
[head_chunks_write_queue_size: <int> | default = 1000000]
# (experimental) When enabled, ingester produces 24h blocks for out-of-order
# data that is before the current day, instead of the usual 2h blocks.
# CLI flag: -blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples
[bigger_out_of_order_blocks_for_old_samples: <boolean> | default = false]
# (advanced) Max size - in bytes - of the in-memory series hash cache. The
# cache is shared across all tenants and it's used only when query sharding is
# enabled.
Expand Down
1 change: 1 addition & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,7 @@ func (i *Ingester) createTSDB(userID string, walReplayConcurrency int) (*userTSD
MaxExemplars: int64(i.limiter.maxExemplarsPerUser(userID)),
SeriesHashCache: i.seriesHashCache,
EnableMemorySnapshotOnShutdown: i.cfg.BlocksStorageConfig.TSDB.MemorySnapshotOnShutdown,
EnableBiggerOOOBlockForOldSamples: i.cfg.BlocksStorageConfig.TSDB.BiggerOutOfOrderBlocksForOldSamples,
IsolationDisabled: true,
HeadChunksWriteQueueSize: i.cfg.BlocksStorageConfig.TSDB.HeadChunksWriteQueueSize,
EnableOverlappingCompaction: false, // always false since Mimir only uploads lvl 1 compacted blocks
Expand Down
38 changes: 20 additions & 18 deletions pkg/storage/tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,25 @@ func (cfg *BlocksStorageConfig) Validate(activeSeriesCfg activeseries.Config) er
//
//nolint:revive
type TSDBConfig struct {
Dir string `yaml:"dir"`
BlockRanges DurationList `yaml:"block_ranges_period" category:"experimental" doc:"hidden"`
Retention time.Duration `yaml:"retention_period"`
ShipInterval time.Duration `yaml:"ship_interval" category:"advanced"`
ShipConcurrency int `yaml:"ship_concurrency" category:"advanced"`
HeadCompactionInterval time.Duration `yaml:"head_compaction_interval" category:"advanced"`
HeadCompactionConcurrency int `yaml:"head_compaction_concurrency" category:"advanced"`
HeadCompactionIdleTimeout time.Duration `yaml:"head_compaction_idle_timeout" category:"advanced"`
HeadChunksWriteBufferSize int `yaml:"head_chunks_write_buffer_size_bytes" category:"advanced"`
HeadChunksEndTimeVariance float64 `yaml:"head_chunks_end_time_variance" category:"experimental"`
StripeSize int `yaml:"stripe_size" category:"advanced"`
WALCompressionEnabled bool `yaml:"wal_compression_enabled" category:"advanced"`
WALSegmentSizeBytes int `yaml:"wal_segment_size_bytes" category:"advanced"`
WALReplayConcurrency int `yaml:"wal_replay_concurrency" category:"advanced"`
FlushBlocksOnShutdown bool `yaml:"flush_blocks_on_shutdown" category:"advanced"`
CloseIdleTSDBTimeout time.Duration `yaml:"close_idle_tsdb_timeout" category:"advanced"`
MemorySnapshotOnShutdown bool `yaml:"memory_snapshot_on_shutdown" category:"experimental"`
HeadChunksWriteQueueSize int `yaml:"head_chunks_write_queue_size" category:"advanced"`
Dir string `yaml:"dir"`
BlockRanges DurationList `yaml:"block_ranges_period" category:"experimental" doc:"hidden"`
Retention time.Duration `yaml:"retention_period"`
ShipInterval time.Duration `yaml:"ship_interval" category:"advanced"`
ShipConcurrency int `yaml:"ship_concurrency" category:"advanced"`
HeadCompactionInterval time.Duration `yaml:"head_compaction_interval" category:"advanced"`
HeadCompactionConcurrency int `yaml:"head_compaction_concurrency" category:"advanced"`
HeadCompactionIdleTimeout time.Duration `yaml:"head_compaction_idle_timeout" category:"advanced"`
HeadChunksWriteBufferSize int `yaml:"head_chunks_write_buffer_size_bytes" category:"advanced"`
HeadChunksEndTimeVariance float64 `yaml:"head_chunks_end_time_variance" category:"experimental"`
StripeSize int `yaml:"stripe_size" category:"advanced"`
WALCompressionEnabled bool `yaml:"wal_compression_enabled" category:"advanced"`
WALSegmentSizeBytes int `yaml:"wal_segment_size_bytes" category:"advanced"`
WALReplayConcurrency int `yaml:"wal_replay_concurrency" category:"advanced"`
FlushBlocksOnShutdown bool `yaml:"flush_blocks_on_shutdown" category:"advanced"`
CloseIdleTSDBTimeout time.Duration `yaml:"close_idle_tsdb_timeout" category:"advanced"`
MemorySnapshotOnShutdown bool `yaml:"memory_snapshot_on_shutdown" category:"experimental"`
HeadChunksWriteQueueSize int `yaml:"head_chunks_write_queue_size" category:"advanced"`
BiggerOutOfOrderBlocksForOldSamples bool `yaml:"bigger_out_of_order_blocks_for_old_samples" category:"experimental"`

// Series hash cache.
SeriesHashCacheMaxBytes uint64 `yaml:"series_hash_cache_max_size_bytes" category:"advanced"`
Expand Down Expand Up @@ -327,6 +328,7 @@ func (cfg *TSDBConfig) RegisterFlags(f *flag.FlagSet) {
f.Int64Var(&cfg.EarlyHeadCompactionMinInMemorySeries, "blocks-storage.tsdb.early-head-compaction-min-in-memory-series", 0, fmt.Sprintf("When the number of in-memory series in the ingester is equal to or greater than this setting, the ingester tries to compact the TSDB Head. The early compaction removes from the memory all samples and inactive series up until -%s time ago. After an early compaction, the ingester will not accept any sample with a timestamp older than -%s time ago (unless out of order ingestion is enabled). The ingester checks every -%s whether an early compaction is required. Use 0 to disable it.", activeseries.IdleTimeoutFlag, activeseries.IdleTimeoutFlag, headCompactionIntervalFlag))
f.IntVar(&cfg.EarlyHeadCompactionMinEstimatedSeriesReductionPercentage, "blocks-storage.tsdb.early-head-compaction-min-estimated-series-reduction-percentage", 15, "When the early compaction is enabled, the early compaction is triggered only if the estimated series reduction is at least the configured percentage (0-100).")
f.BoolVar(&cfg.TimelyHeadCompaction, "blocks-storage.tsdb.timely-head-compaction-enabled", false, "Allows head compaction to happen when the min block range can no longer be appended, without requiring 1.5x the chunk range worth of data in the head.")
f.BoolVar(&cfg.BiggerOutOfOrderBlocksForOldSamples, "blocks-storage.tsdb.bigger-out-of-order-blocks-for-old-samples", false, "When enabled, ingester produces 24h blocks for out-of-order data that is before the current day, instead of the usual 2h blocks.")

cfg.HeadCompactionIntervalJitterEnabled = true
cfg.HeadCompactionIntervalWhileStarting = 30 * time.Second
Expand Down

0 comments on commit f8462ee

Please sign in to comment.