aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/database.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-10-09 21:29:58 +0100
committerChristopher Baines <mail@cbaines.net>2023-10-09 22:19:02 +0100
commit10bad53ad57e92dbc3c6207c251f0af1148e8ffc (patch)
treecf42c97b823461457da74db873f2a968c3060e19 /guix-data-service/database.scm
parent9bb8f84741bdd82b638e3a7a84280687d889fc04 (diff)
downloaddata-service-10bad53ad57e92dbc3c6207c251f0af1148e8ffc.tar
data-service-10bad53ad57e92dbc3c6207c251f0af1148e8ffc.tar.gz
Support polling git repositories for new branches/revisions
This is mostly a workaround for the occasional problems with the guix-commits mailing list, as it can break and then the data service doesn't learn about new revisions until the problem is fixed. I think it's still a generally good feature though, and allows deploying the data service without it consuming emails to learn about new revisions, and is a step towards integrating some kind of way of notifying the data service to poll.
Diffstat (limited to 'guix-data-service/database.scm')
-rw-r--r--guix-data-service/database.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/guix-data-service/database.scm b/guix-data-service/database.scm
index e768d55..756bfef 100644
--- a/guix-data-service/database.scm
+++ b/guix-data-service/database.scm
@@ -39,6 +39,7 @@
check-test-database!
with-advisory-session-lock
+ with-advisory-session-lock/log-time
obtain-advisory-transaction-lock
exec-query-with-null-handling))
@@ -298,6 +299,22 @@
"SELECT pg_advisory_unlock($1)"
(list lock-number))))))
+(define (with-advisory-session-lock/log-time conn lock f)
+ (simple-format #t "debug: Acquiring advisory session lock: ~A\n" lock)
+ (let ((start-time (current-time)))
+ (with-advisory-session-lock
+ conn
+ lock
+ (lambda ()
+ (let ((time-taken (- (current-time) start-time)))
+ (simple-format #t "debug: Finished aquiring lock ~A, took ~A seconds\n"
+ lock time-taken))
+ (let ((result (f)))
+ (let ((time-spent (- (current-time) start-time)))
+ (simple-format #t "debug: Releasing lock ~A, spent ~A seconds\n"
+ lock time-spent))
+ result)))))
+
(define (obtain-advisory-transaction-lock conn lock)
(let ((lock-number (number->string (symbol-hash lock))))
(exec-query conn