Unwind the stack when handling transaction errors

As this avoids trying to suspend while the stack is in a unpredictable state.
This commit is contained in:
Christopher Baines 2025-04-01 22:56:34 +03:00
parent 14de1667b1
commit 97a01853b8

View file

@ -216,13 +216,15 @@
(lambda () (lambda ()
(exec-query conn "ROLLBACK;")) (exec-query conn "ROLLBACK;"))
#:unwind? #t) #:unwind? #t)
;; TODO Include the stack in the exception via knots
(raise-exception exn)) (raise-exception exn))
(lambda () (lambda ()
(let ((result (f conn))) (let ((result (f conn)))
(exec-query conn (if always-rollback? (exec-query conn (if always-rollback?
"ROLLBACK;" "ROLLBACK;"
"COMMIT;")) "COMMIT;"))
result)))) result))
#:unwind? #t))
(define (check-test-database! conn) (define (check-test-database! conn)
(match (exec-query conn "SELECT current_database()") (match (exec-query conn "SELECT current_database()")