Skip to content

Commit c9df53f

Browse files
cdkrotHyukjinKwon
authored andcommitted
[SPARK-46241][PYTHON][CONNECT] Fix error handling routine so it wouldn't fall into infinite recursion
### What changes were proposed in this pull request? Remove _display_server_stack_trace and always display error stack trace if we have one ### Why are the changes needed? There is a certain codepath which can make existing error handling fall into infinite recursion. I.e. consider following codepath: `[Some error happens] -> _handle_error -> _handle_rpc_error -> _display_server_stack_trace -> RuntimeConf.get -> SparkConnectClient.config -> [An error happens] -> _handle_error`. There can be other similar codepaths ### Does this PR introduce _any_ user-facing change? Gets rid of occasionally infinite recursive error handling (which can cause downgraded user experience) ### How was this patch tested? N/A ### Was this patch authored or co-authored using generative AI tooling? No Closes #44144 from cdkrot/forbid_recursive_error_handling. Authored-by: Alice Sayutina <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 89673da commit c9df53f

File tree

1 file changed

+1
-15
lines changed
  • python/pyspark/sql/connect/client

1 file changed

+1
-15
lines changed

python/pyspark/sql/connect/client/core.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,20 +1520,6 @@ def _fetch_enriched_error(self, info: "ErrorInfo") -> Optional[pb2.FetchErrorDet
15201520
except grpc.RpcError:
15211521
return None
15221522

1523-
def _display_server_stack_trace(self) -> bool:
1524-
from pyspark.sql.connect.conf import RuntimeConf
1525-
1526-
conf = RuntimeConf(self)
1527-
try:
1528-
if conf.get("spark.sql.connect.serverStacktrace.enabled") == "true":
1529-
return True
1530-
return conf.get("spark.sql.pyspark.jvmStacktrace.enabled") == "true"
1531-
except Exception as e: # noqa: F841
1532-
# Falls back to true if an exception occurs during reading the config.
1533-
# Otherwise, it will recursively try to get the conf when it consistently
1534-
# fails, ending up with `RecursionError`.
1535-
return True
1536-
15371523
def _handle_rpc_error(self, rpc_error: grpc.RpcError) -> NoReturn:
15381524
"""
15391525
Error handling helper for dealing with GRPC Errors. On the server side, certain
@@ -1567,7 +1553,7 @@ def _handle_rpc_error(self, rpc_error: grpc.RpcError) -> NoReturn:
15671553
info,
15681554
status.message,
15691555
self._fetch_enriched_error(info),
1570-
self._display_server_stack_trace(),
1556+
True,
15711557
) from None
15721558

15731559
raise SparkConnectGrpcException(status.message) from None

0 commit comments

Comments
 (0)