Do DB rollback on failed build insert

This commit is contained in:
Reynir Björnsson 2021-03-25 10:42:04 +01:00
parent 7b5119189d
commit 265e00a718

View file

@ -223,4 +223,11 @@ let add_build
Db.commit () >>= fun () -> Db.commit () >>= fun () ->
commit_files basedir staging_dir job_name uuid commit_files basedir staging_dir job_name uuid
in in
or_cleanup r Lwt_result.bind_lwt_err (or_cleanup r)
(fun e ->
Db.rollback ()
|> Lwt.map (fun r ->
Result.iter_error
(fun e' -> Log.err (fun m -> m "Failed rollback: %a" Caqti_error.pp e'))
r;
e))