From a7f2156ebfe6e20abb2508e090f9e4a75d772480 Mon Sep 17 00:00:00 2001 From: Alexander Chow Date: Tue, 18 Oct 2016 11:05:14 -0700 Subject: [PATCH] Classify worker busy exit code Summary: More exit codes. Reviewed By: oulgen Differential Revision: D4033818 fbshipit-source-id: b688201533f0450fe0a4a82bebecb6a127861661 --- hphp/hack/src/procs/worker.ml | 3 ++- hphp/hack/src/procs/worker.mli | 3 +++ hphp/hack/src/server/serverMain.ml | 3 +++ hphp/hack/src/utils/exit_status.ml | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hphp/hack/src/procs/worker.ml b/hphp/hack/src/procs/worker.ml index 8a3457e4a13..3f3f2b02003 100644 --- a/hphp/hack/src/procs/worker.ml +++ b/hphp/hack/src/procs/worker.ml @@ -34,6 +34,7 @@ open Core exception Worker_exited_abnormally of int exception Worker_oomed +exception Worker_busy (* Should we 'prespawn' the worker ? *) let use_prespawned = not Sys.win32 @@ -267,7 +268,7 @@ let make ?call_wrapper ~saved_state ~entry ~nbr_procs ~gc_control ~heap_handle = let call w (type a) (type b) (f : a -> b) (x : a) : b handle = if w.killed then Printf.ksprintf failwith "killed worker (%d)" w.id; - if w.busy then Printf.ksprintf failwith "busy worker (%d)" w.id; + if w.busy then raise Worker_busy; (* Spawn the slave, if not prespawned. *) let { Daemon.pid = slave_pid; channels = (inc, outc) } as h = match w.prespawned with diff --git a/hphp/hack/src/procs/worker.mli b/hphp/hack/src/procs/worker.mli index 5204fd44153..238cfc17d24 100644 --- a/hphp/hack/src/procs/worker.mli +++ b/hphp/hack/src/procs/worker.mli @@ -21,6 +21,9 @@ exception Worker_exited_abnormally of int (* Worker killed by Out Of Memory. *) exception Worker_oomed +(** Raise this exception when sending work to a worker that is already busy. + * We should never be doing that, and this is an assertion error. *) +exception Worker_busy (* The type of a worker visible to the outside world *) type t diff --git a/hphp/hack/src/server/serverMain.ml b/hphp/hack/src/server/serverMain.ml index cb42af0b70d..1bf45e0631f 100644 --- a/hphp/hack/src/server/serverMain.ml +++ b/hphp/hack/src/server/serverMain.ml @@ -450,6 +450,9 @@ let daemon_main (state, options) (ic, oc) = | Worker.Worker_oomed as e-> Hh_logger.exc e; Exit_status.(exit Worker_oomed) + | Worker.Worker_busy as e -> + Hh_logger.exc e; + Exit_status.(exit Worker_busy) | Decl_class.Decl_heap_elems_bug -> Exit_status.(exit Decl_heap_elems_bug) | SharedMem.C_assertion_failure _ as e -> diff --git a/hphp/hack/src/utils/exit_status.ml b/hphp/hack/src/utils/exit_status.ml index cb3d5418b9e..a00393169f2 100644 --- a/hphp/hack/src/utils/exit_status.ml +++ b/hphp/hack/src/utils/exit_status.ml @@ -28,6 +28,7 @@ type t = | Lost_parent_monitor | Interrupted | Worker_oomed + | Worker_busy | Socket_error | Missing_hhi | Dfind_died @@ -84,6 +85,7 @@ let exit_code = function | Heap_full -> 17 | Interrupted -> -6 | Worker_oomed -> 30 + | Worker_busy -> 31 | Missing_hhi -> 97 | Socket_error -> 98 | Dfind_died -> 99 @@ -134,6 +136,7 @@ let to_string = function | Lost_parent_monitor -> "Lost_parent_monitor" | Interrupted -> "Interrupted" | Worker_oomed -> "Worker_oomed" + | Worker_busy -> "Worker_busy" | Socket_error -> "Socket_error" | Missing_hhi -> "Missing_hhi" | Dfind_died -> "Dfind_died" -- 2.11.4.GIT