[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/07: Try to avoid the metrics timing out
From: |
Christopher Baines |
Subject: |
07/07: Try to avoid the metrics timing out |
Date: |
Thu, 9 Nov 2023 11:45:02 -0500 (EST) |
cbaines pushed a commit to branch master
in repository data-service.
commit 37a07c2d6e8285877ad0440a7e4ae286b7b65177
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Thu Nov 9 16:44:28 2023 +0000
Try to avoid the metrics timing out
As that makes debugging problems harder.
---
guix-data-service/web/controller.scm | 45 ++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 7 deletions(-)
diff --git a/guix-data-service/web/controller.scm
b/guix-data-service/web/controller.scm
index a7ed02c..de7ba7c 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -209,6 +209,17 @@
(metric-set internal-run-time
(get-internal-run-time)))))
+ (define (with-statement-timeout conn proc)
+ (with-postgresql-transaction
+ conn
+ (lambda (conn)
+ (exec-query
+ conn
+ (simple-format #f "SET statement_timeout = ~A" 6000))
+
+ (proc conn))
+ #:always-rollback? #t))
+
(lambda ()
(letpar& ((metric-values
(with-exception-handler
@@ -221,7 +232,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- fetch-high-level-table-size-metrics))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ fetch-high-level-table-size-metrics))))
#:unwind? #t))
(guix-revisions-count
(with-exception-handler
@@ -234,7 +248,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- count-guix-revisions))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ count-guix-revisions))))
#:unwind? #t))
(pg-stat-user-tables-metrics
(with-exception-handler
@@ -247,7 +264,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- fetch-pg-stat-user-tables-metrics))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ fetch-pg-stat-user-tables-metrics))))
#:unwind? #t))
(pg-stat-user-indexes-metrics
(with-exception-handler
@@ -260,7 +280,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- fetch-pg-stat-user-indexes-metrics))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ fetch-pg-stat-user-indexes-metrics))))
#:unwind? #t))
(pg-stats-metric-values
(with-exception-handler
@@ -273,7 +296,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- fetch-pg-stats-metrics))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ fetch-pg-stats-metrics))))
#:unwind? #t))
(load-new-guix-revision-job-metrics
(with-exception-handler
@@ -286,7 +312,10 @@
(lambda ()
(call-with-resource-from-pool
(reserved-connection-pool)
- select-load-new-guix-revision-job-metrics))
+ (lambda (conn)
+ (with-statement-timeout
+ conn
+ select-load-new-guix-revision-job-metrics))))
#:unwind? #t)))
(for-each
@@ -785,7 +814,9 @@
#:sxml (view-statistics guix-revisions-count
count-derivations))))
(('GET "metrics")
- (render-metrics))
+ (parameterize
+ ((resource-pool-default-timeout 6))
+ (render-metrics)))
(('GET "revision" args ...)
(delegate-to revision-controller))
(('GET "repositories")
- branch master updated (2135bc5 -> 37a07c2), Christopher Baines, 2023/11/09
- 05/07: Handle derivations with no sources, Christopher Baines, 2023/11/09
- 02/07: Restore #:error-port when calling open-inferior, Christopher Baines, 2023/11/09
- 01/07: Remove #:use-module (ice-9 custom-ports), Christopher Baines, 2023/11/09
- 07/07: Try to avoid the metrics timing out,
Christopher Baines <=
- 06/07: Add missing empty job log entry, Christopher Baines, 2023/11/09
- 04/07: Handle eof when reading logs, Christopher Baines, 2023/11/09
- 03/07: Remove peek, Christopher Baines, 2023/11/09