Skip to content

Commit 331227c

Browse files
committed
CA-428532: Ensure db flush is executed in shutdown_agent
In `shutdown_agent`, the `xapi_pre_shutdown` may raise exception, then the `light_fuse_and_dont_restart` is skipped. A DB data loss is found because db flush in that funtion is not executed. Signed-off-by: Changlei Li <changlei.li@citrix.com>
1 parent 2f29f5e commit 331227c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

ocaml/xapi/xapi_host.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,13 @@ let restart_agent ~__context ~host:_ =
811811
let shutdown_agent ~__context =
812812
debug "Host.shutdown_agent: Host agent will shutdown in 1s!!!!" ;
813813
let host_uuid = Helpers.get_localhost_uuid () in
814-
Xapi_hooks.xapi_pre_shutdown ~__context ~host_uuid
815-
~reason:Xapi_hooks.reason__clean_shutdown ;
814+
( try
815+
Xapi_hooks.xapi_pre_shutdown ~__context ~host_uuid
816+
~reason:Xapi_hooks.reason__clean_shutdown
817+
with exn ->
818+
warn "%s: xapi_pre_shutdown hook failed: %s" __FUNCTION__
819+
(Printexc.to_string exn)
820+
) ;
816821
Xapi_fuse.light_fuse_and_dont_restart ~fuse_length:1. ()
817822

818823
let disable ~__context ~host ~auto_enable =

0 commit comments

Comments
 (0)