aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-07-12 19:45:41 +0100
committerChristopher Baines <mail@cbaines.net>2019-07-12 19:49:26 +0100
commit743cec7cb675dc6cc792a01daf898c011fc20fc7 (patch)
tree2040ed787544470a2525307e2f7479d3f29e5a90
parent1b5db7adac298e4f0d7e6c9024fc31ebabb4a994 (diff)
downloaddata-service-743cec7cb675dc6cc792a01daf898c011fc20fc7.tar
data-service-743cec7cb675dc6cc792a01daf898c011fc20fc7.tar.gz
Associate a name with database connections
This helps when working out which connection to the database is doing what.
-rw-r--r--guix-data-service/database.scm8
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm1
-rw-r--r--guix-data-service/web/controller.scm2
-rw-r--r--scripts/guix-data-service-process-branch-updated-email.in1
-rw-r--r--scripts/guix-data-service-process-jobs.in1
-rw-r--r--scripts/guix-data-service-query-build-servers.in3
-rw-r--r--tests/branch-updated-emails.scm1
-rw-r--r--tests/jobs-load-new-guix-revision.scm1
-rw-r--r--tests/model-derivation.scm1
-rw-r--r--tests/model-git-branch.scm1
-rw-r--r--tests/model-git-repository.scm1
-rw-r--r--tests/model-license-set.scm1
-rw-r--r--tests/model-license.scm1
-rw-r--r--tests/model-package-metadata.scm1
14 files changed, 20 insertions, 4 deletions
diff --git a/guix-data-service/database.scm b/guix-data-service/database.scm
index ab6758b..acc6dea 100644
--- a/guix-data-service/database.scm
+++ b/guix-data-service/database.scm
@@ -24,10 +24,12 @@
(define pg-conn-finish
(@@ (squee) pg-conn-finish))
-(define (with-postgresql-connection f)
+(define* (with-postgresql-connection name f)
(define paramstring
- (or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
- "dbname=guix_data_service user=guix_data_service"))
+ (string-append
+ (or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
+ "dbname=guix_data_service user=guix_data_service")
+ " application_name='guix-data-service " name "'"))
(let* ((conn (connect-to-postgres-paramstring paramstring)))
(with-throw-handler
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index 4990208..8c53183 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -703,6 +703,7 @@ ORDER BY load_new_guix_revision_jobs.id DESC")
(lambda ()
(let ((result
(with-postgresql-connection
+ (simple-format #f "load-new-guix-revision ~A logging" id)
(lambda (logging-conn)
(insert-empty-log-entry logging-conn id)
(let ((logging-port (log-port id logging-conn)))
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 6cdcd8b..66bc893 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -568,6 +568,7 @@
#t
(lambda ()
(with-postgresql-connection
+ "web healthcheck"
(lambda (conn)
(number?
(string->number
@@ -585,6 +586,7 @@
500))))
(_
(with-postgresql-connection
+ "web"
(lambda (conn)
(controller-with-database-connection request
method-and-path-components
diff --git a/scripts/guix-data-service-process-branch-updated-email.in b/scripts/guix-data-service-process-branch-updated-email.in
index 58fb772..6170a32 100644
--- a/scripts/guix-data-service-process-branch-updated-email.in
+++ b/scripts/guix-data-service-process-branch-updated-email.in
@@ -29,6 +29,7 @@
(guix-data-service branch-updated-emails))
(with-postgresql-connection
+ "process-branch-updated-email"
(lambda (conn)
(enqueue-job-for-email
conn
diff --git a/scripts/guix-data-service-process-jobs.in b/scripts/guix-data-service-process-jobs.in
index e4347e4..51b01bd 100644
--- a/scripts/guix-data-service-process-jobs.in
+++ b/scripts/guix-data-service-process-jobs.in
@@ -31,6 +31,7 @@
(setvbuf (current-error-port) 'line)
(with-postgresql-connection
+ "process-jobs"
(lambda (conn)
(simple-format #t "Ready to process jobs...\n")
(process-jobs conn)))
diff --git a/scripts/guix-data-service-query-build-servers.in b/scripts/guix-data-service-query-build-servers.in
index 2451fbf..b0b3cd0 100644
--- a/scripts/guix-data-service-query-build-servers.in
+++ b/scripts/guix-data-service-query-build-servers.in
@@ -25,4 +25,5 @@
(squee)
(guix-data-service builds))
-(with-postgresql-connection query-build-servers)
+(with-postgresql-connection "query-build-servers"
+ query-build-servers)
diff --git a/tests/branch-updated-emails.scm b/tests/branch-updated-emails.scm
index 0265ba4..b9c92b2 100644
--- a/tests/branch-updated-emails.scm
+++ b/tests/branch-updated-emails.scm
@@ -107,6 +107,7 @@ Summary of changes:
(test-begin "test-branch-updated-emails")
(with-postgresql-connection
+ "test-branch-updated-emails"
(lambda (conn)
(test-assert "enqueue-job-for-email works"
(with-postgresql-transaction
diff --git a/tests/jobs-load-new-guix-revision.scm b/tests/jobs-load-new-guix-revision.scm
index 70a7dfd..35fe655 100644
--- a/tests/jobs-load-new-guix-revision.scm
+++ b/tests/jobs-load-new-guix-revision.scm
@@ -12,6 +12,7 @@
(test-begin "jobs-load-new-guix-revision")
(with-postgresql-connection
+ "test-jobs-load-new-guix-revision"
(lambda (conn)
(test-equal "select-job-for-commit works"
'()
diff --git a/tests/model-derivation.scm b/tests/model-derivation.scm
index 52b113b..eca3768 100644
--- a/tests/model-derivation.scm
+++ b/tests/model-derivation.scm
@@ -6,6 +6,7 @@
(test-begin "test-model-derivation")
(with-postgresql-connection
+ "test-model-derivation"
(lambda (conn)
(test-equal "valid-systems"
'()
diff --git a/tests/model-git-branch.scm b/tests/model-git-branch.scm
index f015cba..a879408 100644
--- a/tests/model-git-branch.scm
+++ b/tests/model-git-branch.scm
@@ -8,6 +8,7 @@
(test-begin "test-model-git-branch")
(with-postgresql-connection
+ "test-module-git-branch"
(lambda (conn)
(test-assert "insert-git-branch-entry works"
(with-postgresql-transaction
diff --git a/tests/model-git-repository.scm b/tests/model-git-repository.scm
index 3129203..befcbfa 100644
--- a/tests/model-git-repository.scm
+++ b/tests/model-git-repository.scm
@@ -6,6 +6,7 @@
(test-begin "test-model-git-repository")
(with-postgresql-connection
+ "test-model-git-repository"
(lambda (conn)
(test-assert "returns an id for a non existent URL"
(with-postgresql-transaction
diff --git a/tests/model-license-set.scm b/tests/model-license-set.scm
index fecf242..9cd949d 100644
--- a/tests/model-license-set.scm
+++ b/tests/model-license-set.scm
@@ -25,6 +25,7 @@
"https://example.com/why-license-2")))))
(with-postgresql-connection
+ "test-model-license-set"
(lambda (conn)
(with-postgresql-transaction
conn
diff --git a/tests/model-license.scm b/tests/model-license.scm
index cdec491..7888117 100644
--- a/tests/model-license.scm
+++ b/tests/model-license.scm
@@ -23,6 +23,7 @@
"https://example.com/why-license-2")))))
(with-postgresql-connection
+ "test-model-license"
(lambda (conn)
(with-postgresql-transaction
conn
diff --git a/tests/model-package-metadata.scm b/tests/model-package-metadata.scm
index f9eccec..ea0cdbe 100644
--- a/tests/model-package-metadata.scm
+++ b/tests/model-package-metadata.scm
@@ -37,6 +37,7 @@
(guix-data-service model package-metadata))
(with-postgresql-connection
+ "test-model-package-metadata"
(lambda (conn)
(test-assert "inferior-packages->package-metadata-ids"
(with-postgresql-transaction