unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#67253] [PATCH] add guix locate database is locked error message(resent)
@ 2023-11-18  0:30 Maciej Kalandyk
  2023-11-26 22:24 ` bug#67253: " Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej Kalandyk @ 2023-11-18  0:30 UTC (permalink / raw)
  To: 67253
  Cc: Maciej Kalandyk, Christopher Baines, Josselin Poiret,
	Ludovic Courtès, Mathieu Othacehe, Ricardo Wurmus,
	Simon Tournier, Tobias Geerinckx-Rice

Change-Id: Iebe76c75d45e70317bd18d2c176dcdeaf9d6964c
Signed-off-by: Maciej Kalandyk <m.kalandyk@outlook.com>
---
 guix/scripts/locate.scm | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/locate.scm b/guix/scripts/locate.scm
index ae64f46896..c24e969be7 100644
--- a/guix/scripts/locate.scm
+++ b/guix/scripts/locate.scm
@@ -115,13 +115,21 @@ (define schema-to-migrate '((1 . "
 ")))
 
 (define (call-with-database file proc)
-  (let ((db (sqlite-open file)))
-    (dynamic-wind
-      (lambda () #t)
-      (lambda ()
-        (ensure-latest-database-schema db)
-        (proc db))
-      (lambda () (sqlite-close db)))))
+  (catch 'sqlite-error
+    (lambda ()
+      (let ((db (sqlite-open file)))
+        (dynamic-wind
+          (lambda () #t)
+          (lambda ()
+            (ensure-latest-database-schema db)
+            (proc db))
+          (lambda () (sqlite-close db)))))
+    (lambda (key . args)
+      (match args
+        [(_ 5 _)
+         (leave (G_ "database ~a is locked by another process~%")
+                file)]
+        [_ (apply throw (cons key args))]))))
 
 (define (ensure-latest-database-schema db)
   "Ensure DB follows the latest known version of the schema."

base-commit: a0d337e79c87d7c38c79d0291974f490cb137a52
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#67253: [PATCH] add guix locate database is locked error message(resent)
  2023-11-18  0:30 [bug#67253] [PATCH] add guix locate database is locked error message(resent) Maciej Kalandyk
@ 2023-11-26 22:24 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2023-11-26 22:24 UTC (permalink / raw)
  To: Maciej Kalandyk
  Cc: 67253-done, Simon Tournier, Mathieu Othacehe,
	Tobias Geerinckx-Rice, Josselin Poiret, Ricardo Wurmus,
	Christopher Baines

Hi,

Maciej Kalandyk <m.kalandyk@outlook.com> skribis:

> Change-Id: Iebe76c75d45e70317bd18d2c176dcdeaf9d6964c
> Signed-off-by: Maciej Kalandyk <m.kalandyk@outlook.com>

I tweaked the exception handler to clarify what’s happening.  The end
result looks like this:

--8<---------------cut here---------------start------------->8---
;; XXX: missing in guile-sqlite3@0.1.3
(define SQLITE_BUSY 5)

(define (call-with-database file proc)
  (catch 'sqlite-error
    (lambda ()
      (let ((db (sqlite-open file)))
        (dynamic-wind
          (lambda () #t)
          (lambda ()
            (ensure-latest-database-schema db)
            (proc db))
          (lambda () (sqlite-close db)))))
    (lambda (key who code errmsg)
      (if (= code SQLITE_BUSY)
          (leave (G_ "~a: database is locked by another process~%")
                 file)
          (throw key who code errmsg)))))
--8<---------------cut here---------------end--------------->8---

Applied, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-26 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-18  0:30 [bug#67253] [PATCH] add guix locate database is locked error message(resent) Maciej Kalandyk
2023-11-26 22:24 ` bug#67253: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).