From 810eb7fe1b9d1614673d521e3698742ab21a61f4 Mon Sep 17 00:00:00 2001 From: s12f <97083380+s12f@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:28:20 +0800 Subject: [PATCH] fix(connector): catch zk exception in handleConnectorRequest (#1624) --- hstream-io/HStream/IO/IOTask.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hstream-io/HStream/IO/IOTask.hs b/hstream-io/HStream/IO/IOTask.hs index b250a8454..2ace6e810 100644 --- a/hstream-io/HStream/IO/IOTask.hs +++ b/hstream-io/HStream/IO/IOTask.hs @@ -33,6 +33,7 @@ import qualified HStream.Stats as Stats import qualified HStream.Utils as Utils import System.Directory (createDirectoryIfMissing) import qualified System.Process.Typed as TP +import qualified ZooKeeper.Exception as E newIOTask :: T.Text -> M.MetaHandle -> Stats.StatsHolder -> TaskInfo -> T.Text -> IOOptions -> IO IOTask newIOTask taskId taskHandle taskStatsHolder taskInfo path ioOptions = do @@ -111,7 +112,11 @@ handleStdout ioTask hStdout hStdin = forever $ do handleConnectorRequest :: IOTask -> MSG.ConnectorRequest -> IO MSG.ConnectorResponse handleConnectorRequest ioTask MSG.ConnectorRequest{..} = do - MSG.ConnectorResponse crId <$> handleConnectorMessage ioTask crMessage + MSG.ConnectorResponse crId <$> E.catch + (handleConnectorMessage ioTask crMessage) + (\(e :: E.ZooException) -> do + Log.warning $ "handleConnectorRequest failed:" <> Log.buildString (show e) <> "ignored" + pure J.Null) handleConnectorMessage :: IOTask -> MSG.ConnectorMessage -> IO J.Value handleConnectorMessage IOTask{..} (MSG.KvGet MSG.KvGetMessage{..}) = J.toJSON <$> M.getTaskKv taskHandle taskId kgKey