Skip to content

Commit

Permalink
Use raise_with_backtrace in with_transaction
Browse files Browse the repository at this point in the history
This stores the original exception backtrace and re-raises after
the async rollback (which destroys the global stack trace).

Fixes with_transaction losing stack traces finally.
  • Loading branch information
brendanlong committed Jun 20, 2018
1 parent 2f29549 commit 7eb0f4c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: ocaml/opam:ubuntu-17.04_ocaml-4.04.2
- image: ocaml/opam:ubuntu-17.04_ocaml-4.05.0
environment:
PGUSER: pgx
PGDATABASE: pgx-test
Expand Down
2 changes: 1 addition & 1 deletion pgx.opam
Expand Up @@ -22,4 +22,4 @@ depends: [
"ounit" {test}
]

available: [ocaml-version >= "4.04.2"]
available: [ocaml-version >= "4.05.0"]
3 changes: 2 additions & 1 deletion pgx/src/pgx.ml
Expand Up @@ -1392,8 +1392,9 @@ module Make (Thread : IO) = struct
return r
)
(fun e ->
let backtrace = Printexc.get_raw_backtrace () in
rollback conn >>= fun () ->
reraise e
Printexc.raise_with_backtrace e backtrace
)

let execute_many conn ~query ~params =
Expand Down
2 changes: 1 addition & 1 deletion pgx_async.opam
Expand Up @@ -18,4 +18,4 @@ depends: [
"ounit" {test}
]

available: [ocaml-version >= "4.04.2"]
available: [ocaml-version >= "4.05.0"]
2 changes: 1 addition & 1 deletion pgx_lwt.opam
Expand Up @@ -18,4 +18,4 @@ depends: [
"ounit" {test}
]

available: [ocaml-version >= "4.04.2"]
available: [ocaml-version >= "4.05.0"]
2 changes: 1 addition & 1 deletion pgx_unix.opam
Expand Up @@ -17,4 +17,4 @@ depends: [
"ounit" {test}
]

available: [ocaml-version >= "4.04.2"]
available: [ocaml-version >= "4.05.0"]

0 comments on commit 7eb0f4c

Please sign in to comment.