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.
This commit is contained in:
Raphaël Proust 2018-11-15 09:56:28 +08:00 committed by Benjamin Canou
parent cd25bb4160
commit c02a970a28

View File

@ -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 let (limits, chain_db) = Prevalidator.parameters old_prevalidator in
(* TODO inject in the new prevalidator the operation (* TODO inject in the new prevalidator the operation
from the previous one. *) from the previous one. *)
Prevalidator.create Prevalidator.create limits (module Proto) chain_db >>= function
limits | Error errs ->
(module Proto) Log.lwt_log_error "@[Failed to reinstantiate prevalidator:@ %a@]"
chain_db >>=? fun prevalidator -> pp_print_error errs >>= fun () ->
nv.prevalidator <- Some prevalidator ; nv.prevalidator <- None ;
Prevalidator.shutdown old_prevalidator >>= fun () -> Prevalidator.shutdown old_prevalidator >>= fun () ->
return_unit return_unit
| Ok prevalidator ->
nv.prevalidator <- Some prevalidator ;
Prevalidator.shutdown old_prevalidator >>= fun () ->
return_unit
end else begin end else begin
Prevalidator.flush old_prevalidator block_hash >>=? fun () -> Prevalidator.flush old_prevalidator block_hash >>=? fun () ->
return_unit return_unit