From c55f74097840338d42f34c17f7253cb3c468edcd Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 13 Oct 2021 14:51:38 +0200 Subject: [PATCH] :sparkles: Update default timeouts on db namespace. --- backend/src/app/db.clj | 17 +++++++++-------- backend/src/app/main.clj | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index 7a86e0e87..2a8d7b785 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -54,7 +54,8 @@ (s/def ::migrations map?) (defmethod ig/pre-init-spec ::pool [_] - (s/keys :req-un [::uri ::name ::min-pool-size ::max-pool-size ::migrations ::mtx/metrics])) + (s/keys :req-un [::uri ::name ::min-pool-size ::max-pool-size ::mtx/metrics] + :opt-un [::migrations])) (defmethod ig/init-key ::pool [_ {:keys [migrations metrics] :as cfg}] @@ -89,8 +90,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def initsql - (str "SET statement_timeout = 120000;\n" - "SET idle_in_transaction_session_timeout = 120000;")) + (str "SET statement_timeout = 200000;\n" + "SET idle_in_transaction_session_timeout = 200000;")) (defn- create-datasource-config [{:keys [metrics] :as cfg}] @@ -104,10 +105,10 @@ (.setPoolName (d/name (:name cfg))) (.setAutoCommit true) (.setReadOnly false) - (.setConnectionTimeout 8000) ;; 8seg - (.setValidationTimeout 8000) ;; 8seg - (.setIdleTimeout 120000) ;; 2min - (.setMaxLifetime 1800000) ;; 30min + (.setConnectionTimeout 10000) ;; 10seg + (.setValidationTimeout 10000) ;; 10seg + (.setIdleTimeout 120000) ;; 2min + (.setMaxLifetime 1800000) ;; 30min (.setMinimumIdle (:min-pool-size cfg 0)) (.setMaximumPoolSize (:max-pool-size cfg 30)) (.setMetricsTrackerFactory mtf) @@ -127,7 +128,7 @@ [pool] (.isClosed ^HikariDataSource pool)) -(defn- create-pool +(defn create-pool [cfg] (let [dsc (create-datasource-config cfg)] (jdbc-dt/read-as-instant) diff --git a/backend/src/app/main.clj b/backend/src/app/main.clj index cdc6f1f95..08c8ef10d 100644 --- a/backend/src/app/main.clj +++ b/backend/src/app/main.clj @@ -20,7 +20,7 @@ :migrations (ig/ref :app.migrations/all) :name :main :min-pool-size 0 - :max-pool-size 20} + :max-pool-size 30} :app.metrics/metrics {:definitions