From 845017103fe9b3d1622cc250948c80ef2727a99c Mon Sep 17 00:00:00 2001 From: ibizaman Date: Fri, 24 Nov 2023 02:16:49 -0800 Subject: [PATCH] automatically cleanup idle connections This is to fix a nextcloud bug that leaves idle connections open which eats into the available postgres connection pool. --- modules/blocks/postgresql.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/blocks/postgresql.nix b/modules/blocks/postgresql.nix index 3b85b84..86b400c 100644 --- a/modules/blocks/postgresql.nix +++ b/modules/blocks/postgresql.nix @@ -47,6 +47,14 @@ in config = let + commonConfig = { + services.postgresql.settings = { + idle_in_transaction_session_timeout = "30s"; + idle_session_timeout = "30s"; + track_io_timing = "true"; + }; + }; + tcpConfig = { services.postgresql.enableTCPIP = true; services.postgresql.authentication = lib.mkOverride 10 '' @@ -102,6 +110,7 @@ in in lib.mkMerge ( [ + commonConfig (dbConfig cfg.ensures) (pwdConfig cfg.ensures) (lib.mkIf cfg.enableTCPIP tcpConfig)