diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-24 08:59:32 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-24 08:59:32 +0100 |
commit | 0cc78b90aec0ccdd8740092a465753cc71bca704 (patch) | |
tree | 55ca4539033cfa4e6ef9705fe5f3f78228912c5a /guix-data-service | |
parent | c61a8afd3646837c2752f9c95306a254d659b2d4 (diff) | |
download | data-service-0cc78b90aec0ccdd8740092a465753cc71bca704.tar data-service-0cc78b90aec0ccdd8740092a465753cc71bca704.tar.gz |
Support setting a statement timeout
To stop queries related to the web server that run for a long time.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/database.scm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/guix-data-service/database.scm b/guix-data-service/database.scm index 455ce82..df4daac 100644 --- a/guix-data-service/database.scm +++ b/guix-data-service/database.scm @@ -34,7 +34,7 @@ (define pg-conn-finish (@@ (squee) pg-conn-finish)) -(define* (with-postgresql-connection name f) +(define* (with-postgresql-connection name f #:key (statement-timeout #f)) (define paramstring (string-append (or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING") @@ -47,6 +47,11 @@ (let* ((conn (connect-to-postgres-paramstring (or (getenv "GUIX_DATA_SERVICE_DATABASE_URI") paramstring)))) + (when statement-timeout + (exec-query + conn + (simple-format #f "SET statement_timeout = ~A" + statement-timeout))) (with-throw-handler #t (lambda () |