From c02a970a28ef479d3cbefd3d32d15aa5fb925e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Thu, 15 Nov 2018 09:56:28 +0800 Subject: [PATCH] Shell/mempool: handle failure to re-instantiate prevalidator When the protocol changes, the prevalidator is re-instantiated. In case this fails, the old-prevalidator still needs to be shutdown. --- src/lib_shell/chain_validator.ml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib_shell/chain_validator.ml b/src/lib_shell/chain_validator.ml index 47ce3764a..21f754b82 100644 --- a/src/lib_shell/chain_validator.ml +++ b/src/lib_shell/chain_validator.ml @@ -301,13 +301,17 @@ let on_request (type a) w spawn_child (req : a Request.t) : a tzresult Lwt.t = let (limits, chain_db) = Prevalidator.parameters old_prevalidator in (* TODO inject in the new prevalidator the operation from the previous one. *) - Prevalidator.create - limits - (module Proto) - chain_db >>=? fun prevalidator -> - nv.prevalidator <- Some prevalidator ; - Prevalidator.shutdown old_prevalidator >>= fun () -> - return_unit + Prevalidator.create limits (module Proto) chain_db >>= function + | Error errs -> + Log.lwt_log_error "@[Failed to reinstantiate prevalidator:@ %a@]" + pp_print_error errs >>= fun () -> + nv.prevalidator <- None ; + Prevalidator.shutdown old_prevalidator >>= fun () -> + return_unit + | Ok prevalidator -> + nv.prevalidator <- Some prevalidator ; + Prevalidator.shutdown old_prevalidator >>= fun () -> + return_unit end else begin Prevalidator.flush old_prevalidator block_hash >>=? fun () -> return_unit