Skip to content

Commit 365c517

Browse files
committed
kill supervisor upon unrecoverable errors in child
See discussion on PR haskell-distributed#87.
1 parent 4f2e602 commit 365c517

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Control/Distributed/Process/Platform/Supervisor.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,19 +1169,21 @@ doRestartChild _ spec _ state = do -- TODO: use ProcessId and DiedReason to log
11691169
case start' of
11701170
Right (ref, st') -> do
11711171
return $ markActive st' ref spec
1172-
Left err -> do -- TODO: handle this by policy
1172+
Left err -> do
11731173
-- All child failures are handled via monitor signals, apart from
11741174
-- BadClosure and UnresolvableAddress from the StarterProcess
11751175
-- variants of ChildStart, which both come back from
11761176
-- doStartChild as (Left err).
11771177
-- Since we cannot recover from that, there's no point in trying
11781178
-- to start this child again (as the closure will never resolve),
1179-
-- so we remove the child forthwith. We should provide a policy
1180-
-- for handling this situation though...
1179+
-- so we remove the child forthwith.
11811180
sup <- getSelfPid
11821181
logEntry Log.error $
11831182
mkReport "Unrecoverable error in child" sup (childKey spec) (show err)
1184-
return $ ( (active ^: Map.filter (/= chKey))
1183+
if (isTemporary (childRestart spec))
1184+
-- TODO: convert this to a meaningful exception type
1185+
then die $ "Unrecoverable error in child " ++ (childKey spec)
1186+
else return $ ( (active ^: Map.filter (/= chKey))
11851187
. (bumpStats Active chType decrement)
11861188
. (bumpStats Specified chType decrement)
11871189
$ removeChild spec st

0 commit comments

Comments
 (0)