From 771f0cc2eea52766b105726f65ff38dc17060e50 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 1 Mar 2024 14:24:14 +0100 Subject: [PATCH 1/4] Detect deadlock in subscribe node --- matter_server/server/device_controller.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index cfc8bd7b..5331dbda 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -14,6 +14,7 @@ import time from typing import TYPE_CHECKING, Any, Callable, Iterable, TypeVar, cast +import async_timeout from chip.ChipDeviceCtrl import DeviceProxyWrapper from chip.clusters import Attribute, Objects as Clusters from chip.clusters.Attribute import ValueDecodeFailure @@ -1111,7 +1112,14 @@ async def _setup_node(self, node_id: int) -> None: return # setup subscriptions for the node try: - await self._subscribe_node(node_id) + async with async_timeout.timeout(1800): + await self._subscribe_node(node_id) + except TimeoutError: + LOGGER.error( + "POSSIBLE DEADLOCK DETECTED - REPORT TO HOME ASSISTANT DEVELOPERS: " + "Setting up subscriptions for node %s did not succeed after 30 minutes. ", + node_id, + ) except (NodeNotResolving, ChipStackError) as err: LOGGER.warning( "Unable to subscribe to Node %s: %s", From 3ba875958ad12b3d17ef2cacfea31ec4aff9d156 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 1 Mar 2024 14:31:50 +0100 Subject: [PATCH 2/4] typo --- matter_server/server/device_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index 5331dbda..4d41a491 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -1117,7 +1117,7 @@ async def _setup_node(self, node_id: int) -> None: except TimeoutError: LOGGER.error( "POSSIBLE DEADLOCK DETECTED - REPORT TO HOME ASSISTANT DEVELOPERS: " - "Setting up subscriptions for node %s did not succeed after 30 minutes. ", + "Setting up subscriptions for node %s did not succeed after 30 minutes.", node_id, ) except (NodeNotResolving, ChipStackError) as err: From 0a6cfc291c5c60ac1ee0a618b8a5e9629b0958ff Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 1 Mar 2024 14:44:41 +0100 Subject: [PATCH 3/4] cool down the messaging --- matter_server/server/device_controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index 4d41a491..841fb3a2 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -1112,12 +1112,12 @@ async def _setup_node(self, node_id: int) -> None: return # setup subscriptions for the node try: - async with async_timeout.timeout(1800): + async with async_timeout.timeout(15 * 60 * 60): await self._subscribe_node(node_id) except TimeoutError: - LOGGER.error( - "POSSIBLE DEADLOCK DETECTED - REPORT TO HOME ASSISTANT DEVELOPERS: " - "Setting up subscriptions for node %s did not succeed after 30 minutes.", + LOGGER.warning( + "Setting up subscriptions for node %s did not " + "succeed after 15 minutes!", node_id, ) except (NodeNotResolving, ChipStackError) as err: From 3849dbb9c2479683945c92dee975bf27c0191569 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 1 Mar 2024 14:50:14 +0100 Subject: [PATCH 4/4] 15 minutes, not 15 hours --- matter_server/server/device_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index 841fb3a2..9504faa0 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -1112,7 +1112,7 @@ async def _setup_node(self, node_id: int) -> None: return # setup subscriptions for the node try: - async with async_timeout.timeout(15 * 60 * 60): + async with async_timeout.timeout(15 * 60): await self._subscribe_node(node_id) except TimeoutError: LOGGER.warning(