From c935bf7d2264e91f79e88194800eceb10c9f4b3b Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Thu, 4 Sep 2025 16:53:08 +0300 Subject: [PATCH 1/2] query_timeout_fix --- api/graph.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/api/graph.py b/api/graph.py index 030305da..87e2a443 100644 --- a/api/graph.py +++ b/api/graph.py @@ -57,7 +57,7 @@ async def _query_graph( graph, query: str, params: Dict[str, Any] = None, - timeout: int = 120 + timeout: int = 300 ) -> List[Any]: """ Run a graph query asynchronously and return the result set. @@ -178,8 +178,13 @@ async def _find_tables_sphere( nullable: columns.nullable }) """ - tasks = [_query_graph(graph, query, {"name": name}) for name in tables] - results = await asyncio.gather(*tasks) + try: + tasks = [_query_graph(graph, query, {"name": name}) for name in tables] + results = await asyncio.gather(*tasks) + except Exception as e: + logging.error("Error finding tables in sphere: %s", e) + results = [] + return [row for rows in results for row in rows] @@ -206,7 +211,7 @@ async def _find_connecting_tables( MATCH (a:Table {name: pair[0]}) MATCH (b:Table {name: pair[1]}) WITH a, b - MATCH p = allShortestPaths((a)-[*..9]-(b)) + MATCH p = allShortestPaths((a)-[*..6]-(b)) UNWIND nodes(p) AS path_node WITH DISTINCT path_node WHERE 'Table' IN labels(path_node) OR @@ -234,7 +239,12 @@ async def _find_connecting_tables( }) AS columns RETURN target_table.name, target_table.description, target_table.foreign_keys, columns """ - result = await _query_graph(graph, query, {"pairs": pairs}, timeout=300) + try: + result = await _query_graph(graph, query, {"pairs": pairs}, timeout=500) + except Exception as e: + logging.error("Error finding connecting tables: %s", e) + result = [] + return result From b22c275e9d74ffe2908009feccba5426f437d0b1 Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Thu, 4 Sep 2025 16:56:03 +0300 Subject: [PATCH 2/2] lint --- api/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/graph.py b/api/graph.py index 87e2a443..4007c37c 100644 --- a/api/graph.py +++ b/api/graph.py @@ -13,7 +13,7 @@ from api.extensions import db logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") - +# pylint: disable=broad-exception-caught class TableDescription(BaseModel): """Table Description"""