Michael Smith has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/23831 )
Change subject: IMPALA-14460: Keep http connections open in impala-shell ...................................................................... IMPALA-14460: Keep http connections open in impala-shell Leave HS2-HTTP connections open and retry on 401 or EPIPE failures to re-use connections, greatly reducing the number of client connections needed with the HS2-HTTP protocol. Adds a 'use_new_http_connection' impala-shell option to restore the old behavior of using a new connection for each rpc. Existing test_shell_interactive_reconnect tests that ImpalaShell - the library implementing the impala-shell CLI - will automatically establish a new connection with all protocols. Prior to this patch, after restarting impalad you'd see 2026-01-06 11:13:08 [Warning] close session RPC failed: <class 'impala_shell.shell_exceptions.RPCException'> ERROR: Invalid session id: be40a2618203ff7b:beacd4b5d28f7692 Connection lost, reconnecting... Warning: --connect_timeout_ms is currently ignored with HTTP transport. Opened TCP connection to localhost:28001 If you instead introduce a load balancer like haproxy and restart the lb, there's no apparent break because impala-shell would always establish a new connection. With this patch, when impalad is restarted we still see the lost session 2026-01-06 11:20:43 [Exception] type=<class 'BrokenPipeError'> in PingImpalaHS2Service. Num remaining tries: 3 [Errno 32] Broken pipe Connection closed, reconnecting... 2026-01-06 11:20:43 [Warning] close session RPC failed: <class 'impala_shell.shell_exceptions.RPCException'> ERROR: Invalid session id: 6e494c76a9a58278:dbb7016cb5999385 Connection lost, reconnecting... Warning: --connect_timeout_ms is currently ignored with HTTP transport. Opened TCP connection to localhost:28000 If the lb is restarted, we now see that the connection is reopened 2026-01-06 11:24:02 [Exception] type=<class 'BrokenPipeError'> in PingImpalaHS2Service. Num remaining tries: 3 [Errno 32] Broken pipe Connection closed, reconnecting... Query: ... Triggering a retry due to 401 Unauthorized requires Kerberos, since Basic and Bearer auth always send the Authorization header; it shows 2026-01-06 17:02:27 [Exception] type= <class 'http.client.RemoteDisconnected'> in ExecuteStatement. Remote end closed connection without response 2026-01-06 17:02:27 [Exception] type= <class 'http.client.RemoteDisconnected'> when listing query options. Num remaining tries: 3 Remote end closed connection without response 2026-01-06 17:02:27 [Exception] type=<class 'ConnectionRefusedError'> in ExecuteStatement. [Errno 111] Connection refused 2026-01-06 17:02:27 [Exception] type=<class 'ConnectionRefusedError'> when listing query options. Num remaining tries: 2 [Errno 111] Connection refused Connection closed, reconnecting... Cookies expired, restarting authentication... Preserving cookies: impala.auth Connected to localhost:28005 Updates tests that count RPCs via number of connections as re-use means they're no longer linked. Tests now rely on connection count, which verifies we're re-using connections. Adds testReconnect to use a proxy where we can interrupt the existing connection, which will sometimes trigger "Connection closed, reconnecting..." I didn't find a way to trigger it consistently in this test environment. Adds tests using Kerberos authentication to trigger cookie retry and "Cookie expired, restarting authentication..." Generated-by: Github Copilot (GPT-4.1) Change-Id: Iafb3fc39817e93c691cd993902c6d939a7235a03 Reviewed-on: http://gerrit.cloudera.org:8080/23831 Tested-by: Impala Public Jenkins <[email protected]> Reviewed-by: Michael Smith <[email protected]> --- M fe/src/test/java/org/apache/impala/customcluster/LdapImpalaShellTest.java M fe/src/test/java/org/apache/impala/customcluster/LdapKerberosImpalaShellTest.java M fe/src/test/java/org/apache/impala/customcluster/LdapSearchBindImpalaShellTest.java M fe/src/test/java/org/apache/impala/customcluster/LdapSimpleBindImpalaShellTest.java A fe/src/test/java/org/apache/impala/testutil/InterruptibleProxyServer.java M shell/impala_shell/ImpalaHttpClient.py M shell/impala_shell/impala_client.py M shell/impala_shell/impala_shell.py M shell/impala_shell/option_parser.py M tests/custom_cluster/test_hs2_fault_injection.py M tests/custom_cluster/test_shell_commandline.py M tests/custom_cluster/test_shell_jwt_auth.py M tests/custom_cluster/test_shell_oauth_auth.py M tests/shell/test_shell_interactive.py 14 files changed, 380 insertions(+), 83 deletions(-) Approvals: Impala Public Jenkins: Verified Michael Smith: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/23831 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Iafb3fc39817e93c691cd993902c6d939a7235a03 Gerrit-Change-Number: 23831 Gerrit-PatchSet: 8 Gerrit-Owner: Michael Smith <[email protected]> Gerrit-Reviewer: Csaba Ringhofer <[email protected]> Gerrit-Reviewer: Gergely Farkas <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Jason Fehr <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Pranav Lodha <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
