Skip to content

Commit 8624712

Browse files
authored
Enable metadata caching by blocks scanner. (#2640)
* Blocks scanner can benefit from metadata caching. Signed-off-by: Peter Štibraný <[email protected]> * CHANGELOG.md Signed-off-by: Peter Štibraný <[email protected]>
1 parent 44d2724 commit 8624712

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* `cortex_compactor_block_cleanup_completed_total`
4949
* `cortex_compactor_block_cleanup_failed_total`
5050
* `cortex_compactor_block_cleanup_last_successful_run_timestamp_seconds`
51-
* [ENHANCEMENT] Experimental TSDB: Use shared cache for metadata. This is especially useful when running multiple querier and store-gateway components to reduce number of object store API calls. #2626
51+
* [ENHANCEMENT] Experimental TSDB: Use shared cache for metadata. This is especially useful when running multiple querier and store-gateway components to reduce number of object store API calls. #2626 #2640
5252
* [ENHANCEMENT] Upgrade Thanos to [f7802edbf830](https://github.com/thanos-io/thanos/commit/f7802edbf830) and Prometheus to [f4dd45609a05](https://github.com/prometheus/prometheus/commit/f4dd45609a05) which is after v2.18.1. #2634
5353
* TSDB now does memory-mapping of Head chunks and reduces memory usage.
5454
* [ENHANCEMENT] Experimental TSDB: when `-querier.query-store-after` is configured and running the experimental blocks storage, the time range of the query sent to the store is now manipulated to ensure the query end time is not more recent than 'now - query-store-after'. #2642

pkg/querier/blocks_store_queryable.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/prometheus/prometheus/promql"
1919
"github.com/prometheus/prometheus/storage"
2020
"github.com/thanos-io/thanos/pkg/block/metadata"
21+
"github.com/thanos-io/thanos/pkg/extprom"
2122
"github.com/thanos-io/thanos/pkg/store/hintspb"
2223
"github.com/thanos-io/thanos/pkg/store/storepb"
2324
"github.com/weaveworks/common/user"
@@ -131,6 +132,13 @@ func NewBlocksStoreQueryableFromConfig(querierCfg Config, gatewayCfg storegatewa
131132
return nil, errors.Wrap(err, "failed to create bucket client")
132133
}
133134

135+
// Blocks scanner doesn't use chunks, but we pass config for consistency.
136+
cachingBucket, err := cortex_tsdb.CreateCachingBucket(storageCfg.BucketStore.ChunksCache, storageCfg.BucketStore.MetadataCache, bucketClient, logger, extprom.WrapRegistererWith(prometheus.Labels{"component": "querier"}, reg))
137+
if err != nil {
138+
return nil, errors.Wrapf(err, "create caching bucket")
139+
}
140+
bucketClient = cachingBucket
141+
134142
scanner := NewBlocksScanner(BlocksScannerConfig{
135143
ScanInterval: storageCfg.BucketStore.SyncInterval,
136144
TenantsConcurrency: storageCfg.BucketStore.TenantSyncConcurrency,

0 commit comments

Comments
 (0)