Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Index Header Configs #5726

Merged
merged 20 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* [CHANGE] The `-shutdown-delay` flag is no longer experimental. #5701
* [CHANGE] The `-validation.create-grace-period` is now enforced in the ingester too, other than distributor and query-frontend. If you've configured `-validation.create-grace-period` then make sure the configuration is applied to ingesters too. #5712
* [CHANGE] The `-validation.create-grace-period` is now enforced for examplars too in the distributor. If an examplar has timestamp greater than "now + grace_period", then the exemplar will be dropped and the metric `cortex_discarded_exemplars_total{reason="exemplar_too_far_in_future",user="..."}` increased. #5761
* [CHANGE] Store-gateway: deprecate and move configuration parameters for index header under `blocks-storage.bucket-store` to `blocks-storage.bucket-store.index-header`, deprecated configuration will be removed in Mimir 2.12. Configuration changes: #5726
* `-blocks-storage.bucket-store.index-header-lazy-loading-enabled` is deprecated and moved to `-blocks-storage.bucket-store.index-header.lazy-loading-enabled`
* `-blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout` is deprecated and moved to `-blocks-storage.bucket-store.index-header.lazy-loading-idle-timeout`
* `-blocks-storage.bucket-store.index-header-lazy-loading-concurrency` is moved to `-blocks-storage.bucket-store.index-header.lazy-loading-concurrency`
* [FEATURE] Introduced `distributor.service_overload_status_code_on_rate_limit_enabled` flag for configuring status code to 529 instead of 429 upon rate limit exhaustion. #5752
* [FEATURE] Cardinality API: Add a new `count_method` parameter which enables counting active series #5136
* [FEATURE] Query-frontend: added experimental support to cache cardinality, label names and label values query responses. The cache will be used when `-query-frontend.cache-results` is enabled, and `-query-frontend.results-cache-ttl-for-cardinality-query` or `-query-frontend.results-cache-ttl-for-labels-query` set to a value greater than 0. The following metrics have been added to track the query results cache hit ratio per `request_type`: #5212 #5235 #5426 #5524
Expand Down
70 changes: 46 additions & 24 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -7558,7 +7558,7 @@
"fieldDefaultValue": true,
"fieldFlag": "blocks-storage.bucket-store.index-header-lazy-loading-enabled",
"fieldType": "boolean",
"fieldCategory": "advanced"
"fieldCategory": "deprecated"
},
{
"kind": "field",
Expand All @@ -7569,29 +7569,7 @@
"fieldDefaultValue": 3600000000000,
"fieldFlag": "blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout",
"fieldType": "duration",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "index_header_lazy_loading_concurrency",
"required": false,
"desc": "Maximum number of concurrent index header loads across all tenants. If set to 0, concurrency is unlimited.",
"fieldValue": null,
"fieldDefaultValue": 0,
"fieldFlag": "blocks-storage.bucket-store.index-header-lazy-loading-concurrency",
"fieldType": "int",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "index_header_sparse_persistence_enabled",
"required": false,
"desc": "If enabled, store-gateway will persist a sparse version of the index-header to disk on construction and load sparse index-headers from disk instead of the whole index-header.",
"fieldValue": null,
"fieldDefaultValue": false,
"fieldFlag": "blocks-storage.bucket-store.index-header-sparse-persistence-enabled",
"fieldType": "boolean",
"fieldCategory": "experimental"
"fieldCategory": "deprecated"
},
{
"kind": "field",
Expand Down Expand Up @@ -7643,6 +7621,50 @@
"fieldType": "boolean",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "lazy_loading_enabled",
"required": false,
"desc": "If enabled, store-gateway will lazy load an index-header only once required by a query.",
"fieldValue": null,
"fieldDefaultValue": true,
"fieldFlag": "blocks-storage.bucket-store.index-header.lazy-loading-enabled",
"fieldType": "boolean",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "lazy_loading_idle_timeout",
"required": false,
"desc": "If index-header lazy loading is enabled and this setting is \u003e 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity.",
"fieldValue": null,
"fieldDefaultValue": 3600000000000,
"fieldFlag": "blocks-storage.bucket-store.index-header.lazy-loading-idle-timeout",
"fieldType": "duration",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "lazy_loading_concurrency",
"required": false,
"desc": "Maximum number of concurrent index header loads across all tenants. If set to 0, concurrency is unlimited.",
"fieldValue": null,
"fieldDefaultValue": 0,
"fieldFlag": "blocks-storage.bucket-store.index-header.lazy-loading-concurrency",
"fieldType": "int",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "sparse_persistence_enabled",
"required": false,
"desc": "If enabled, store-gateway will persist a sparse version of the index-header to disk on construction and load sparse index-headers from disk instead of the whole index-header.",
"fieldValue": null,
"fieldDefaultValue": false,
"fieldFlag": "blocks-storage.bucket-store.index-header.sparse-persistence-enabled",
"fieldType": "boolean",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "verify_on_load",
Expand Down
16 changes: 10 additions & 6 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,22 @@ Usage of ./cmd/mimir/mimir:
Username to use when connecting to Redis.
-blocks-storage.bucket-store.index-cache.redis.write-timeout duration
Client write timeout. (default 3s)
-blocks-storage.bucket-store.index-header-lazy-loading-concurrency int
[experimental] Maximum number of concurrent index header loads across all tenants. If set to 0, concurrency is unlimited.
-blocks-storage.bucket-store.index-header-lazy-loading-enabled
If enabled, store-gateway will lazy load an index-header only once required by a query. (default true)
[deprecated] If enabled, store-gateway will lazy load an index-header only once required by a query. (default true)
-blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout duration
If index-header lazy loading is enabled and this setting is > 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity. (default 1h0m0s)
-blocks-storage.bucket-store.index-header-sparse-persistence-enabled
[experimental] If enabled, store-gateway will persist a sparse version of the index-header to disk on construction and load sparse index-headers from disk instead of the whole index-header.
[deprecated] If index-header lazy loading is enabled and this setting is > 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity. (default 1h0m0s)
-blocks-storage.bucket-store.index-header.eager-loading-startup-enabled
[experimental] If enabled, store-gateway will periodically persist block IDs of lazy loaded index-headers and load them eagerly during startup. It is not valid to enable this if index-header lazy loading is disabled.
-blocks-storage.bucket-store.index-header.lazy-loading-concurrency int
[experimental] Maximum number of concurrent index header loads across all tenants. If set to 0, concurrency is unlimited.
-blocks-storage.bucket-store.index-header.lazy-loading-enabled
If enabled, store-gateway will lazy load an index-header only once required by a query. (default true)
-blocks-storage.bucket-store.index-header.lazy-loading-idle-timeout duration
If index-header lazy loading is enabled and this setting is > 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity. (default 1h0m0s)
-blocks-storage.bucket-store.index-header.max-idle-file-handles uint
Maximum number of idle file handles the store-gateway keeps open for each index-header file. (default 1)
-blocks-storage.bucket-store.index-header.sparse-persistence-enabled
[experimental] If enabled, store-gateway will persist a sparse version of the index-header to disk on construction and load sparse index-headers from disk instead of the whole index-header.
-blocks-storage.bucket-store.index-header.verify-on-load
If true, verify the checksum of index headers upon loading them (either on startup or lazily when lazy loading is enabled). Setting to true helps detect disk corruption at the cost of slowing down index header loading.
-blocks-storage.bucket-store.max-chunk-pool-bytes uint
Expand Down
39 changes: 25 additions & 14 deletions docs/sources/mimir/references/configuration-parameters/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3405,28 +3405,17 @@ bucket_store:
# CLI flag: -blocks-storage.bucket-store.series-hash-cache-max-size-bytes
[series_hash_cache_max_size_bytes: <int> | default = 1073741824]

# (advanced) If enabled, store-gateway will lazy load an index-header only
# (deprecated) If enabled, store-gateway will lazy load an index-header only
# once required by a query.
# CLI flag: -blocks-storage.bucket-store.index-header-lazy-loading-enabled
[index_header_lazy_loading_enabled: <boolean> | default = true]

# (advanced) If index-header lazy loading is enabled and this setting is > 0,
# the store-gateway will offload unused index-headers after 'idle timeout'
# (deprecated) If index-header lazy loading is enabled and this setting is >
# 0, the store-gateway will offload unused index-headers after 'idle timeout'
# inactivity.
# CLI flag: -blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout
[index_header_lazy_loading_idle_timeout: <duration> | default = 1h]

# (experimental) Maximum number of concurrent index header loads across all
# tenants. If set to 0, concurrency is unlimited.
# CLI flag: -blocks-storage.bucket-store.index-header-lazy-loading-concurrency
[index_header_lazy_loading_concurrency: <int> | default = 0]

# (experimental) If enabled, store-gateway will persist a sparse version of
# the index-header to disk on construction and load sparse index-headers from
# disk instead of the whole index-header.
# CLI flag: -blocks-storage.bucket-store.index-header-sparse-persistence-enabled
[index_header_sparse_persistence_enabled: <boolean> | default = false]

# (advanced) Max size - in bytes - of a gap for which the partitioner
# aggregates together two bucket GET object requests.
# CLI flag: -blocks-storage.bucket-store.partitioner-max-gap-bytes
Expand All @@ -3449,6 +3438,28 @@ bucket_store:
# CLI flag: -blocks-storage.bucket-store.index-header.eager-loading-startup-enabled
[eager_loading_startup_enabled: <boolean> | default = false]

# (advanced) If enabled, store-gateway will lazy load an index-header only
# once required by a query.
# CLI flag: -blocks-storage.bucket-store.index-header.lazy-loading-enabled
[lazy_loading_enabled: <boolean> | default = true]

# (advanced) If index-header lazy loading is enabled and this setting is >
# 0, the store-gateway will offload unused index-headers after 'idle
# timeout' inactivity.
# CLI flag: -blocks-storage.bucket-store.index-header.lazy-loading-idle-timeout
[lazy_loading_idle_timeout: <duration> | default = 1h]

# (experimental) Maximum number of concurrent index header loads across all
# tenants. If set to 0, concurrency is unlimited.
# CLI flag: -blocks-storage.bucket-store.index-header.lazy-loading-concurrency
[lazy_loading_concurrency: <int> | default = 0]

# (experimental) If enabled, store-gateway will persist a sparse version of
# the index-header to disk on construction and load sparse index-headers
# from disk instead of the whole index-header.
# CLI flag: -blocks-storage.bucket-store.index-header.sparse-persistence-enabled
[sparse_persistence_enabled: <boolean> | default = false]

# (advanced) If true, verify the checksum of index headers upon loading them
# (either on startup or lazily when lazy loading is enabled). Setting to
# true helps detect disk corruption at the cost of slowing down index header
Expand Down
9 changes: 9 additions & 0 deletions pkg/mimir/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,15 @@ func (t *Mimir) initCompactor() (serv services.Service, err error) {
func (t *Mimir) initStoreGateway() (serv services.Service, err error) {
t.Cfg.StoreGateway.ShardingRing.ListenPort = t.Cfg.Server.GRPCListenPort

// TODO: Remove in Mimir 2.12.
// Take value from Indexheader DeprecatedConfig if it is set
if t.Cfg.BlocksStorage.BucketStore.DeprecatedIndexHeaderLazyLoadingEnabled {
t.Cfg.BlocksStorage.BucketStore.IndexHeader.LazyLoadingEnabled = t.Cfg.BlocksStorage.BucketStore.DeprecatedIndexHeaderLazyLoadingEnabled
}
if t.Cfg.BlocksStorage.BucketStore.DeprecatedIndexHeaderLazyLoadingIdleTimeout > 0 {
t.Cfg.BlocksStorage.BucketStore.IndexHeader.LazyLoadingIdleTimeout = t.Cfg.BlocksStorage.BucketStore.DeprecatedIndexHeaderLazyLoadingIdleTimeout
}

t.StoreGateway, err = storegateway.NewStoreGateway(t.Cfg.StoreGateway, t.Cfg.BlocksStorage, t.Overrides, util_log.Logger, t.Registerer, t.ActivityTracker)
if err != nil {
return nil, err
Expand Down
22 changes: 5 additions & 17 deletions pkg/storage/tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ var (
errInvalidEarlyHeadCompactionMinSeriesReduction = errors.New("early compaction minimum series reduction percentage must be a value between 0 and 100 (included)")
errEarlyCompactionRequiresActiveSeries = fmt.Errorf("early compaction requires -%s to be enabled", activeseries.EnabledFlag)
errEmptyBlockranges = errors.New("empty block ranges for TSDB")
errInvalidIndexHeaderLazyLoadingConcurrency = errors.New("invalid index-header lazy loading max concurrency; must be non-negative")
)

// BlocksStorageConfig holds the config information for the blocks storage.
Expand Down Expand Up @@ -389,14 +388,8 @@ type BucketStoreConfig struct {
SeriesHashCacheMaxBytes uint64 `yaml:"series_hash_cache_max_size_bytes" category:"advanced"`

// Controls whether index-header lazy loading is enabled.
IndexHeaderLazyLoadingEnabled bool `yaml:"index_header_lazy_loading_enabled" category:"advanced"`
IndexHeaderLazyLoadingIdleTimeout time.Duration `yaml:"index_header_lazy_loading_idle_timeout" category:"advanced"`

// Maximum index-headers loaded into store-gateway concurrently
IndexHeaderLazyLoadingConcurrency int `yaml:"index_header_lazy_loading_concurrency" category:"experimental"`

// Controls whether persisting a sparse version of the index-header to disk is enabled.
IndexHeaderSparsePersistenceEnabled bool `yaml:"index_header_sparse_persistence_enabled" category:"experimental"`
DeprecatedIndexHeaderLazyLoadingEnabled bool `yaml:"index_header_lazy_loading_enabled" category:"deprecated"` // Deprecated. TODO: Remove in Mimir 2.12.
DeprecatedIndexHeaderLazyLoadingIdleTimeout time.Duration `yaml:"index_header_lazy_loading_idle_timeout" category:"deprecated"` // Deprecated. TODO: Remove in Mimir 2.12.

// Controls the partitioner, used to aggregate multiple GET object API requests.
PartitionerMaxGapBytes uint64 `yaml:"partitioner_max_gap_bytes" category:"advanced"`
Expand Down Expand Up @@ -455,10 +448,8 @@ func (cfg *BucketStoreConfig) RegisterFlags(f *flag.FlagSet) {
"The idea of ignore-deletion-marks-delay is to ignore blocks that are marked for deletion with some delay. This ensures store can still serve blocks that are meant to be deleted but do not have a replacement yet.")
f.DurationVar(&cfg.IgnoreBlocksWithin, "blocks-storage.bucket-store.ignore-blocks-within", 10*time.Hour, "Blocks with minimum time within this duration are ignored, and not loaded by store-gateway. Useful when used together with -querier.query-store-after to prevent loading young blocks, because there are usually many of them (depending on number of ingesters) and they are not yet compacted. Negative values or 0 disable the filter.")
f.IntVar(&cfg.PostingOffsetsInMemSampling, "blocks-storage.bucket-store.posting-offsets-in-mem-sampling", DefaultPostingOffsetInMemorySampling, "Controls what is the ratio of postings offsets that the store will hold in memory.")
f.BoolVar(&cfg.IndexHeaderLazyLoadingEnabled, "blocks-storage.bucket-store.index-header-lazy-loading-enabled", true, "If enabled, store-gateway will lazy load an index-header only once required by a query.")
f.DurationVar(&cfg.IndexHeaderLazyLoadingIdleTimeout, "blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout", 60*time.Minute, "If index-header lazy loading is enabled and this setting is > 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity.")
f.IntVar(&cfg.IndexHeaderLazyLoadingConcurrency, "blocks-storage.bucket-store.index-header-lazy-loading-concurrency", 0, "Maximum number of concurrent index header loads across all tenants. If set to 0, concurrency is unlimited.")
f.BoolVar(&cfg.IndexHeaderSparsePersistenceEnabled, "blocks-storage.bucket-store.index-header-sparse-persistence-enabled", false, "If enabled, store-gateway will persist a sparse version of the index-header to disk on construction and load sparse index-headers from disk instead of the whole index-header.")
f.BoolVar(&cfg.DeprecatedIndexHeaderLazyLoadingEnabled, "blocks-storage.bucket-store.index-header-lazy-loading-enabled", true, "If enabled, store-gateway will lazy load an index-header only once required by a query.")
f.DurationVar(&cfg.DeprecatedIndexHeaderLazyLoadingIdleTimeout, "blocks-storage.bucket-store.index-header-lazy-loading-idle-timeout", 60*time.Minute, "If index-header lazy loading is enabled and this setting is > 0, the store-gateway will offload unused index-headers after 'idle timeout' inactivity.")
f.Uint64Var(&cfg.PartitionerMaxGapBytes, "blocks-storage.bucket-store.partitioner-max-gap-bytes", DefaultPartitionerMaxGapSize, "Max size - in bytes - of a gap for which the partitioner aggregates together two bucket GET object requests.")
f.IntVar(&cfg.StreamingBatchSize, "blocks-storage.bucket-store.batch-series-size", 5000, "This option controls how many series to fetch per batch. The batch size must be greater than 0.")
f.IntVar(&cfg.ChunkRangesPerSeries, "blocks-storage.bucket-store.fine-grained-chunks-caching-ranges-per-series", 1, "This option controls into how many ranges the chunks of each series from each block are split. This value is effectively the number of chunks cache items per series per block when -blocks-storage.bucket-store.chunks-cache.fine-grained-chunks-caching-enabled is enabled.")
Expand Down Expand Up @@ -498,12 +489,9 @@ func (cfg *BucketStoreConfig) Validate(logger log.Logger) error {
if cfg.SeriesSelectionStrategyName == WorstCasePostingsStrategy && cfg.SelectionStrategies.WorstCaseSeriesPreference <= 0 {
return errors.New("invalid worst-case series preference; must be positive")
}
if err := cfg.IndexHeader.Validate(cfg.IndexHeaderLazyLoadingEnabled); err != nil {
if err := cfg.IndexHeader.Validate(); err != nil {
return errors.Wrap(err, "index-header configuration")
}
if cfg.IndexHeaderLazyLoadingConcurrency < 0 {
return errInvalidIndexHeaderLazyLoadingConcurrency
}
return nil
}

Expand Down
Loading