diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index 81e2d9d09..6604df6b5 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -7,7 +7,6 @@ (ns app.db (:require [app.common.data :as d] - [app.common.data.macros :as dm] [app.common.exceptions :as ex] [app.common.geom.point :as gpt] [app.common.logging :as l] @@ -61,22 +60,17 @@ (s/def ::validation-timeout ::us/integer) (s/def ::read-only? ::us/boolean) -(s/def ::statement-timeout ::us/integer) -(s/def ::idle-in-transaction-timeout ::us/integer) - (s/def ::pool-options (s/keys :opt-un [::uri ::name ::min-size ::max-size ::connection-timeout ::validation-timeout - ::statement-timeout - ::idle-in-transaction-timeout ::migrations ::username ::password - ::read-only? - ::mtx/metrics])) + ::mtx/metrics + ::read-only?])) (def defaults {:name :main @@ -86,8 +80,6 @@ :validation-timeout 10000 :idle-timeout 120000 ; 2min :max-lifetime 1800000 ; 30m - :statement-timeout 300000 - :idle-in-transaction-timeout 300000 :read-only? false}) (defmethod ig/prep-key ::pool @@ -135,6 +127,10 @@ ;; API & Impl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(def initsql + (str "SET statement_timeout = 300000;\n" + "SET idle_in_transaction_session_timeout = 300000;")) + (defn- create-datasource-config [{:keys [metrics uri] :as cfg}] (let [config (HikariConfig.)] @@ -149,11 +145,7 @@ (.setMaxLifetime (:max-lifetime cfg)) (.setMinimumIdle (:min-size cfg)) (.setMaximumPoolSize (:max-size cfg)) - (.setConnectionInitSql - (dm/fmt "SET statement_timeout=%; SET idle_in_transaction_session_timeout=%;" - (:statement-timeout cfg) - (:idle-in-transaction-timeout cfg))) - + (.setConnectionInitSql initsql) (.setInitializationFailTimeout -1)) ;; When metrics namespace is provided