Rebuild search indexes asynchronously (#111829)

* Add "debouncer" queue, which can combine incoming elements.

* Rebuild indexes asynchronously.

* Remove duplicate method.

* Fix bleve tests.

* Extracted combineRebuildRequests and added test for it.

* Add TestShouldRebuildIndex

* Added TestFindIndexesForRebuild

* Added TestFindIndexesForRebuild

* Introduce index_rebuild_workers option.

* Add metric for rebuild queue length.

* Add TestRebuildIndexes.

* Fix import.

* Linter, review feedback.
This commit is contained in:
Peter Štibraný
2025-10-01 11:52:09 +02:00
committed by GitHub
parent 91e8eb0e45
commit 707c486a46
11 changed files with 1009 additions and 285 deletions
+3 -2
View File
@@ -575,13 +575,14 @@ type Cfg struct {
MaxPageSizeBytes int
IndexPath string
IndexWorkers int
IndexRebuildWorkers int
IndexMaxBatchSize int
IndexFileThreshold int
IndexMinCount int
IndexRebuildInterval time.Duration
IndexCacheTTL time.Duration
MaxFileIndexAge time.Duration // Max age of file-based indexes. Index older than this will not be reused between restarts.
MinFileIndexBuildVersion string // Minimum version of Grafana that built the file-based index. If index was built with older Grafana, it will not be reused between restarts.
MaxFileIndexAge time.Duration // Max age of file-based indexes. Index older than this will be rebuilt asynchronously.
MinFileIndexBuildVersion string // Minimum version of Grafana that built the file-based index. If index was built with older Grafana, it will be rebuilt asynchronously.
EnableSharding bool
QOSEnabled bool
QOSNumberWorker int
+1
View File
@@ -54,6 +54,7 @@ func (cfg *Cfg) setUnifiedStorageConfig() {
cfg.MaxPageSizeBytes = section.Key("max_page_size_bytes").MustInt(0)
cfg.IndexPath = section.Key("index_path").String()
cfg.IndexWorkers = section.Key("index_workers").MustInt(10)
cfg.IndexRebuildWorkers = section.Key("index_rebuild_workers").MustInt(5)
cfg.IndexMaxBatchSize = section.Key("index_max_batch_size").MustInt(100)
cfg.EnableSharding = section.Key("enable_sharding").MustBool(false)
cfg.QOSEnabled = section.Key("qos_enabled").MustBool(false)