[ 
https://issues.apache.org/jira/browse/SPARK-58619?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jiwon Park updated SPARK-58619:
-------------------------------
    Component/s: Spark Core
    Description: 
The {{INVALID_HANDLE}} session sub-conditions ({{SESSION_CHANGED}}, 
{{SESSION_CLOSED}}, {{SESSION_NOT_FOUND}}) mean the server-side session backing 
a Connect client is gone, which SQL standard {{08003}} (connection does not 
exist) describes. They inherit {{INVALID_HANDLE}}'s generic {{HY000}}, so tools 
detecting dead connections by SQLSTATE class {{08}} cannot recognize them, and 
the Connect JDBC driver hard-codes a remapping as a workaround (raised in the 
SPARK-57933 review).

Renaming them into a class-08 condition is not viable: released Connect clients 
match the condition names for session invalidation and reattach re-execution, 
and nothing in a new client can repair that direction. Per the PR discussion, 
support an optional sub-condition level {{sqlState}} in the error framework as 
a documented wire-compatibility exception and assign {{08003}} to the three 
session sub-conditions, with guardrails: the error README documents the 
exception, discourages new overrides even within the same error class, and 
notes a future server-side compatibility layer may remove it; a new 
{{SparkThrowableSuite}} invariant fails any sub-condition {{sqlState}} outside 
an explicit allowlist.


  was:
{{INVALID_HANDLE}} (SQLSTATE {{HY000}}, class {{HY}} = CLI-specific condition) 
currently groups two unrelated families of sub-conditions:

* {{FORMAT}}, {{OPERATION_ABANDONED}}, {{OPERATION_ALREADY_EXISTS}}, 
{{OPERATION_NOT_FOUND}} - a malformed or misused handle on a healthy session, 
which {{HY000}} describes adequately.
* {{SESSION_CHANGED}}, {{SESSION_CLOSED}}, {{SESSION_NOT_FOUND}} - the 
server-side session backing a Connect client is gone, which SQL standard 
{{08003}} (connection does not exist) describes. These inherited {{HY000}} 
accidentally: {{INVALID_HANDLE}} received it when it only covered 
handle-validity errors (SPARK-44422), and the session sub-conditions were 
folded in later.

Consequences: tools that detect dead connections by SQLSTATE class {{08}} 
cannot recognize these errors, so the Connect JDBC driver hard-codes a 
{{SESSION_*}} -> {{08003}} remapping (raised in the SPARK-57933 review); and 
since {{getMessageTemplate}} concatenates the parent and sub-condition 
messages, {{SESSION_CHANGED}} renders as "The handle xxx is invalid. The 
existing Spark server driver instance has restarted." although the handle is 
valid.

Per the review consensus on the original PR (sub-condition level SQLSTATE 
override was rejected in favor of restructuring), move the three session 
sub-conditions to a new top-level condition {{SESSION_UNAVAILABLE}} with 
SQLSTATE {{08003}}, sub-conditions {{CHANGED}} / {{CLOSED}} / {{NOT_FOUND}}, 
and the message "The session <handle> is no longer available."; 
{{INVALID_HANDLE}} keeps {{FORMAT}} and the {{OPERATION_*}} sub-conditions with 
{{HY000}}. Released Connect clients match the old condition names to drive 
session invalidation and transparent reattach, so the reattach matchers accept 
both the old and new names, and the rename is noted in the migration guide.


        Summary: Assign SQLSTATE 08003 to the INVALID_HANDLE session 
sub-conditions  (was: Split the INVALID_HANDLE session sub-conditions into a 
new SESSION_UNAVAILABLE error condition with SQLSTATE 08003)

> Assign SQLSTATE 08003 to the INVALID_HANDLE session sub-conditions
> ------------------------------------------------------------------
>
>                 Key: SPARK-58619
>                 URL: https://issues.apache.org/jira/browse/SPARK-58619
>             Project: Spark
>          Issue Type: Improvement
>          Components: Connect, Spark Core
>    Affects Versions: 4.3.0
>            Reporter: Jiwon Park
>            Priority: Major
>              Labels: pull-request-available
>
> The {{INVALID_HANDLE}} session sub-conditions ({{SESSION_CHANGED}}, 
> {{SESSION_CLOSED}}, {{SESSION_NOT_FOUND}}) mean the server-side session 
> backing a Connect client is gone, which SQL standard {{08003}} (connection 
> does not exist) describes. They inherit {{INVALID_HANDLE}}'s generic 
> {{HY000}}, so tools detecting dead connections by SQLSTATE class {{08}} 
> cannot recognize them, and the Connect JDBC driver hard-codes a remapping as 
> a workaround (raised in the SPARK-57933 review).
> Renaming them into a class-08 condition is not viable: released Connect 
> clients match the condition names for session invalidation and reattach 
> re-execution, and nothing in a new client can repair that direction. Per the 
> PR discussion, support an optional sub-condition level {{sqlState}} in the 
> error framework as a documented wire-compatibility exception and assign 
> {{08003}} to the three session sub-conditions, with guardrails: the error 
> README documents the exception, discourages new overrides even within the 
> same error class, and notes a future server-side compatibility layer may 
> remove it; a new {{SparkThrowableSuite}} invariant fails any sub-condition 
> {{sqlState}} outside an explicit allowlist.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to