Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Use the search cluster lock for both init indexing and re-indexing (#70272)

Nathan Voxlandd7f7d8285f45
diff --git a/src/metabase/search/task/search_index.clj b/src/metabase/search/task/search_index.clj
index b8ce1e8f111..5ed31f890e1 100644
--- a/src/metabase/search/task/search_index.clj
+++ b/src/metabase/search/task/search_index.clj
@@ -18,6 +18,7 @@
(def ^:private init-stem "metabase.task.search-index.init")
(def ^:private reindex-stem "metabase.task.search-index.reindex")
+(def ^:private cluster-lock-name ::search-index-lock)
(def init-job-key
"Key used to define and trigger a job that ensures there is an active index."
@@ -33,13 +34,14 @@
"Create a new index, if necessary"
[]
(when (search/supports-index?)
- (cluster-lock/with-cluster-lock ::search-init-lock
+ (cluster-lock/with-cluster-lock cluster-lock-name
(search/init-index! {:force-reset? false, :re-populate? false}))))
(task/defjob ^{DisallowConcurrentExecution true
:doc "Populate a new Search Index"}
SearchIndexReindex [_ctx]
- (search/reindex! {:async? false}))
+ (cluster-lock/with-cluster-lock cluster-lock-name
+ (search/reindex! {:async? false})))
(defmethod startup/def-startup-logic! ::SearchIndexInit [_]
(doto (Thread. ^Runnable init!) .start))