Skip to content

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

Include lock name in cluster lock log and error messages (#71677)

Edward Paget4b032951ad0c
diff --git a/src/metabase/app_db/cluster_lock.clj b/src/metabase/app_db/cluster_lock.clj
index 78d62b5a9bb..fd9c8f9fda0 100644
--- a/src/metabase/app_db/cluster_lock.clj
+++ b/src/metabase/app_db/cluster_lock.clj
@@ -59,7 +59,7 @@
(t2/query-one {:insert-into [:metabase_cluster_lock]
:columns [:lock_name]
:values [[lock-name-str]]})))
- (log/debug "Obtained cluster lock")
+ (log/debugf "Obtained cluster lock: %s" lock-name-str)
(thunk)))
(mu/defn do-with-cluster-lock
@@ -85,8 +85,9 @@
(do-with-cluster-lock* lock-name-str timeout-seconds thunk))
(catch Throwable e
(if (retryable? e)
- (throw (ex-info "Failed to run statement with cluster lock"
- {:retries (:max-retries config)}
+ (throw (ex-info (str "Failed to obtain cluster lock: " lock-name-str)
+ {:lock-name lock-name
+ :retries (:max-retries config)}
e))
(throw e)))))))
diff --git a/test/metabase/app_db/cluster_lock_test.clj b/test/metabase/app_db/cluster_lock_test.clj
index 8414400f0cb..f70f0357187 100644
--- a/test/metabase/app_db/cluster_lock_test.clj
+++ b/test/metabase/app_db/cluster_lock_test.clj
@@ -24,7 +24,7 @@
(future (sut/with-cluster-lock ::test-lock (a/>!! ready-chan :ready) (a/<!! fin-chan)))
(a/<!! ready-chan) ;; make sure the future above starts
(is (thrown-with-msg?
- clojure.lang.ExceptionInfo #"Failed to run statement with cluster lock"
+ clojure.lang.ExceptionInfo #"Failed to obtain cluster lock"
(sut/with-cluster-lock ::test-lock (Thread/sleep 1))))
(a/>!! fin-chan :done)))
(testing "cluster no retry on other error"