From 3e0fc04067bee6e2891147c5eb8547d9afe841f6 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 7 Nov 2022 12:39:01 -0800 Subject: [PATCH 1/5] Added debugging Signed-off-by: Ian Costanzo --- aries_cloudagent/protocols/routing/v1_0/manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index 44c1b7b7c6..008b13af3a 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -1,5 +1,6 @@ """Routing manager classes for tracking and inspecting routing records.""" +import logging from typing import Coroutine, Sequence from ....core.error import BaseError @@ -16,6 +17,9 @@ from .models.route_updated import RouteUpdated +LOGGER = logging.getLogger(__name__) + + class RoutingManagerError(BaseError): """Generic routing error.""" @@ -55,15 +59,19 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: raise RoutingManagerError("Must pass non-empty recip_verkey") try: + LOGGER.error(">>> fetching routing record for verkey: " + recip_verkey) async with self._profile.session() as session: record = await RouteRecord.retrieve_by_recipient_key( session, recip_verkey ) + LOGGER.error(">>> FOUND routing record for verkey: " + recip_verkey) except StorageDuplicateError: + LOGGER.error(">>> DUPLICATE routing record for verkey: " + recip_verkey) raise RouteNotFoundError( f"More than one route record found with recipient key: {recip_verkey}" ) except StorageNotFoundError: + LOGGER.error(">>> NOT FOUND routing record for verkey: " + recip_verkey) raise RouteNotFoundError( f"No route found with recipient key: {recip_verkey}" ) @@ -136,6 +144,7 @@ async def create_route_record( ) if not recipient_key: raise RoutingManagerError("Missing recipient_key") + LOGGER.error(">>> creating routing record for verkey: " + recipient_key) route = RouteRecord( connection_id=client_connection_id, wallet_id=internal_wallet_id, @@ -143,6 +152,7 @@ async def create_route_record( ) async with self._profile.session() as session: await route.save(session, reason="Created new route") + LOGGER.error(">>> CREATED routing record for verkey: " + recipient_key) return route async def update_routes( From 1128f041820133a7378dcd0adbae94037569ec75 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 7 Nov 2022 13:41:33 -0800 Subject: [PATCH 2/5] Debugging Signed-off-by: Ian Costanzo --- .../protocols/routing/v1_0/manager.py | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index 008b13af3a..5ac5656dd2 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -1,5 +1,6 @@ """Routing manager classes for tracking and inspecting routing records.""" +import asyncio import logging from typing import Coroutine, Sequence @@ -58,25 +59,30 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: if not recip_verkey: raise RoutingManagerError("Must pass non-empty recip_verkey") - try: - LOGGER.error(">>> fetching routing record for verkey: " + recip_verkey) - async with self._profile.session() as session: - record = await RouteRecord.retrieve_by_recipient_key( - session, recip_verkey + pause = True + record = None + while not record: + try: + LOGGER.error(">>> fetching routing record for verkey: " + recip_verkey) + async with self._profile.session() as session: + record = await RouteRecord.retrieve_by_recipient_key( + session, recip_verkey + ) + LOGGER.error(">>> FOUND routing record for verkey: " + recip_verkey) + return record + except StorageDuplicateError: + LOGGER.error(">>> DUPLICATE routing record for verkey: " + recip_verkey) + raise RouteNotFoundError( + f"More than one route record found with recipient key: {recip_verkey}" ) - LOGGER.error(">>> FOUND routing record for verkey: " + recip_verkey) - except StorageDuplicateError: - LOGGER.error(">>> DUPLICATE routing record for verkey: " + recip_verkey) - raise RouteNotFoundError( - f"More than one route record found with recipient key: {recip_verkey}" - ) - except StorageNotFoundError: - LOGGER.error(">>> NOT FOUND routing record for verkey: " + recip_verkey) - raise RouteNotFoundError( - f"No route found with recipient key: {recip_verkey}" - ) - - return record + except StorageNotFoundError: + LOGGER.error(">>> NOT FOUND routing record for verkey: " + recip_verkey) + if not pause: + raise RouteNotFoundError( + f"No route found with recipient key: {recip_verkey}" + ) + await asyncio.wait(500) + pause = False async def get_routes( self, client_connection_id: str = None, tag_filter: dict = None From 215c9cca85afb1012718f12ce985dfa9d8f14004 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 7 Nov 2022 13:59:34 -0800 Subject: [PATCH 3/5] Debugging Signed-off-by: Ian Costanzo --- aries_cloudagent/protocols/routing/v1_0/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index 5ac5656dd2..babed988de 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -81,7 +81,7 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: raise RouteNotFoundError( f"No route found with recipient key: {recip_verkey}" ) - await asyncio.wait(500) + await asyncio.sleep(0.5) pause = False async def get_routes( From f9bc5f85b27c340e567c4a2e7f761a44fffefc99 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 7 Nov 2022 14:21:40 -0800 Subject: [PATCH 4/5] Debugging Signed-off-by: Ian Costanzo --- .../protocols/routing/v1_0/manager.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index babed988de..33408d0e7c 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -20,6 +20,9 @@ LOGGER = logging.getLogger(__name__) +RECIP_ROUTE_PAUSE = 0.1 +RECIP_ROUTE_RETRY = 5 + class RoutingManagerError(BaseError): """Generic routing error.""" @@ -59,30 +62,30 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: if not recip_verkey: raise RoutingManagerError("Must pass non-empty recip_verkey") - pause = True + i = 0 record = None while not record: try: - LOGGER.error(">>> fetching routing record for verkey: " + recip_verkey) + LOGGER.info(">>> fetching routing record for verkey: " + recip_verkey) async with self._profile.session() as session: record = await RouteRecord.retrieve_by_recipient_key( session, recip_verkey ) - LOGGER.error(">>> FOUND routing record for verkey: " + recip_verkey) + LOGGER.info(">>> FOUND routing record for verkey: " + recip_verkey) return record except StorageDuplicateError: - LOGGER.error(">>> DUPLICATE routing record for verkey: " + recip_verkey) + LOGGER.info(">>> DUPLICATE routing record for verkey: " + recip_verkey) raise RouteNotFoundError( f"More than one route record found with recipient key: {recip_verkey}" ) except StorageNotFoundError: - LOGGER.error(">>> NOT FOUND routing record for verkey: " + recip_verkey) - if not pause: + LOGGER.info(">>> NOT FOUND routing record for verkey: " + recip_verkey) + i += 1 + if i > RECIP_ROUTE_RETRY: raise RouteNotFoundError( f"No route found with recipient key: {recip_verkey}" ) - await asyncio.sleep(0.5) - pause = False + await asyncio.sleep(RECIP_ROUTE_PAUSE) async def get_routes( self, client_connection_id: str = None, tag_filter: dict = None @@ -150,7 +153,7 @@ async def create_route_record( ) if not recipient_key: raise RoutingManagerError("Missing recipient_key") - LOGGER.error(">>> creating routing record for verkey: " + recipient_key) + LOGGER.info(">>> creating routing record for verkey: " + recipient_key) route = RouteRecord( connection_id=client_connection_id, wallet_id=internal_wallet_id, @@ -158,7 +161,7 @@ async def create_route_record( ) async with self._profile.session() as session: await route.save(session, reason="Created new route") - LOGGER.error(">>> CREATED routing record for verkey: " + recipient_key) + LOGGER.info(">>> CREATED routing record for verkey: " + recipient_key) return route async def update_routes( From 0e0ccdd8795c21210ace4a5db76aeddb8efd2828 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 7 Nov 2022 15:05:45 -0800 Subject: [PATCH 5/5] Debugging Signed-off-by: Ian Costanzo --- aries_cloudagent/protocols/routing/v1_0/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index 33408d0e7c..d200a30b59 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -21,7 +21,7 @@ LOGGER = logging.getLogger(__name__) RECIP_ROUTE_PAUSE = 0.1 -RECIP_ROUTE_RETRY = 5 +RECIP_ROUTE_RETRY = 10 class RoutingManagerError(BaseError):