You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Joe McDonnell (Code Review)" <ge...@cloudera.org> on 2026/02/24 06:39:59 UTC

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Joe McDonnell has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24026


Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................

IMPALA-14776 (part 1): Use context managers for manually created clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies most locations using these APIs to use with-as or
try-finally blocks to guarantee cleanup. This also updates the
comment on those APIs to recommend these structures over manually
closing the client. In general, we prefer with-as over
try-finally. try-finally must manually list each thing to close
in the finally block and it is not obvious when one is missing.

This also bundles a few other minor fixes for resource leaks of
sockets. This modifies some locations that already close the
client and aren't currently causing problems.

This doesn't address leaks from tests using ThreadLocalClient. That
will come in an additional change.

Testing:
 - Ran a core job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
---
M tests/authorization/test_authorization.py
M tests/authorization/test_ranger.py
M tests/common/impala_test_suite.py
M tests/custom_cluster/test_admission_controller.py
M tests/custom_cluster/test_breakpad.py
M tests/custom_cluster/test_executor_groups.py
M tests/custom_cluster/test_external_planner.py
M tests/custom_cluster/test_incremental_metadata_updates.py
M tests/custom_cluster/test_logging.py
M tests/custom_cluster/test_query_live.py
M tests/custom_cluster/test_query_log.py
M tests/custom_cluster/test_re2_max_mem.py
M tests/custom_cluster/test_udf_concurrency.py
M tests/hs2/test_hs2.py
M tests/metadata/test_ddl_base.py
M tests/metadata/test_event_processing.py
M tests/query_test/test_beeswax.py
M tests/query_test/test_kudu.py
M tests/statestore/test_statestore.py
M tests/stress/test_merge_stress.py
M tests/stress/test_update_stress.py
21 files changed, 891 insertions(+), 867 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/26/24026/1
-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 3:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py
File tests/common/impala_test_suite.py:

http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py@276
PS3, Line 276:     cls.test_method_scoped_clients = []
I think that this should be an instance member, or a class member in ImpalaTestSuite - see ImpalaTestSuite.impalad_test_service below.


http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py@506
PS3, Line 506:     # cls.client should be equal to one of below, unless test method implicitly override.
             :     # Closing twice would lead to error in some clients (impyla+SSL).
This states that closing is not always idempotent - can this be an issue for the new logic?



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Thu, 26 Feb 2026 07:48:53 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 1:

(20 comments)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@114
PS1, Line 114: )
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2771
PS1, Line 2771: \
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2819
PS1, Line 2819: )
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2822
PS1, Line 2822: )
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@3999
PS1, Line 3999: m
flake8: U100 Unused argument 'method'


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_breakpad.py
File tests/custom_cluster/test_breakpad.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_breakpad.py@207
PS1, Line 207: )
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py
File tests/custom_cluster/test_executor_groups.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py@780
PS1, Line 780: e
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py@852
PS1, Line 852: l
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_re2_max_mem.py
File tests/custom_cluster/test_re2_max_mem.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_re2_max_mem.py@39
PS1, Line 39: l
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_udf_concurrency.py
File tests/custom_cluster/test_udf_concurrency.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_udf_concurrency.py@82
PS1, Line 82: e
flake8: F841 local variable 'e' is assigned to but never used


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py
File tests/metadata/test_event_processing.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@522
PS1, Line 522: )
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@527
PS1, Line 527: )
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@597
PS1, Line 597: )
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@605
PS1, Line 605: a
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@662
PS1, Line 662: l
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@724
PS1, Line 724: n
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@727
PS1, Line 727: 9
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@743
PS1, Line 743: n
flake8: E501 line too long (91 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@744
PS1, Line 744: i
flake8: E501 line too long (92 > 90 characters)


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@746
PS1, Line 746: 9
flake8: E501 line too long (92 > 90 characters)



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 06:42:28 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 5: Verified+1 Code-Review+1

Carry +1s as only the commit message changed.


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 5
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 02:46:40 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4: Code-Review+1

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24026/4//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24026/4//COMMIT_MSG@31
PS4, Line 31: the these methods appropriately.
typo: "the these"



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Mon, 02 Mar 2026 23:30:36 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24026/4//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24026/4//COMMIT_MSG@31
PS4, Line 31: the these methods appropriately.
> typo: "the these"
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 02:46:15 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Csaba Ringhofer, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24026

to look at the new patch set (#3).

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................

IMPALA-14776 (part 1): Auto-close manually created impala clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies those APIs to register the clients in a list and
close them during test method teardown. That should prevent
resource leaks (sockets, sessions) associated with these clients.
The clients may have been cleaned up by other means (with-as or
try-finally or a manual close), so it is heavily relying on
close() being idempotent.

ImpalaTestSuite's built-in clients use an internal API so that
they can be reused across test methods. They instead are scoped
at the class level.

This also bundles a few other minor fixes for resource leaks of
sockets.

Testing:
 - Ran a core job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
---
M tests/common/impala_test_suite.py
M tests/hs2/test_hs2.py
M tests/statestore/test_statestore.py
3 files changed, 63 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/26/24026/3
-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24026

to look at the new patch set (#2).

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................

IMPALA-14776 (part 1): Use context managers for manually created clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies most locations using these APIs to use with-as or
try-finally blocks to guarantee cleanup. This also updates the
comment on those APIs to recommend these structures over manually
closing the client. In general, we prefer with-as over
try-finally. try-finally must manually list each thing to close
in the finally block and it is not obvious when one is missing.

This also bundles a few other minor fixes for resource leaks of
sockets. This modifies some locations that already close the
client and aren't currently causing problems.

This doesn't address leaks from tests using ThreadLocalClient. That
will come in an additional change.

Testing:
 - Ran a core job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
---
M tests/authorization/test_authorization.py
M tests/authorization/test_ranger.py
M tests/common/impala_test_suite.py
M tests/custom_cluster/test_admission_controller.py
M tests/custom_cluster/test_breakpad.py
M tests/custom_cluster/test_executor_groups.py
M tests/custom_cluster/test_external_planner.py
M tests/custom_cluster/test_incremental_metadata_updates.py
M tests/custom_cluster/test_logging.py
M tests/custom_cluster/test_query_live.py
M tests/custom_cluster/test_query_log.py
M tests/custom_cluster/test_re2_max_mem.py
M tests/custom_cluster/test_udf_concurrency.py
M tests/hs2/test_hs2.py
M tests/metadata/test_ddl_base.py
M tests/metadata/test_event_processing.py
M tests/query_test/test_beeswax.py
M tests/query_test/test_kudu.py
M tests/statestore/test_statestore.py
M tests/stress/test_merge_stress.py
M tests/stress/test_update_stress.py
21 files changed, 899 insertions(+), 865 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/26/24026/2
-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 5:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24026/5/tests/custom_cluster/test_scratch_disk.py
File tests/custom_cluster/test_scratch_disk.py:

http://gerrit.cloudera.org:8080/#/c/24026/5/tests/custom_cluster/test_scratch_disk.py@97
PS5, Line 97: ImpalaTestSuite
> Maybe it would be better to have a base class like ManualCustomCluster test
It's a bit weird to bypass the parent method and go to the grandparent method. I wasn't sure what would be cleaner. I was thinking about adding a decorator like "with_args" (or maybe a special arg to with_args) to tell CustomClusterTestSuite not to start up the cluster.

Another thing I saw while looking at this:
There are a bunch of setup_class() methods that are either pointless (they just call super) or only exist to skip if it isn't exhaustive. We don't need the first set. We could avoid the second set by using SkipIfExploration.is_not_exhaustive(). Fewer custom setup_class() methods is probably a good thing.



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 5
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Mar 2026 08:08:52 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 2: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 11:46:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13174/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Mon, 02 Mar 2026 20:40:32 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21834/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Mon, 02 Mar 2026 20:51:18 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 3: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/13149/


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Thu, 26 Feb 2026 10:13:26 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 01:03:12 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 2:

(2 comments)

I've reworked this to avoid touching all of the test code. It now registers the client when it is created and cleans it up during test method teardown.

http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG@8
PS2, Line 8: 
> Not sure if you are aware of my patch https://gerrit.cloudera.org/#/c/23992
Yeah, I was focusing on different things. Now it is in, so I'm stacking on top of that change.


http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG@20
PS2, Line 20: This modifies most locations using these APIs to use with-as or
            : try-finally blocks to guarantee cleanup.
> I was also thinking about how to handle these, and adding a "with" everywhe
Good point, I changed this to maintain a list of clients and clean them up at the end of a test method. To keep it minimal, I'm not really touching any of the test code.



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Thu, 26 Feb 2026 05:43:08 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 3:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13149/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Thu, 26 Feb 2026 05:43:55 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 1:

(20 comments)

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@114
PS1, Line 114: )
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2771
PS1, Line 2771: \
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2819
PS1, Line 2819: )
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@2822
PS1, Line 2822: )
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/authorization/test_ranger.py@3999
PS1, Line 3999: m
> flake8: U100 Unused argument 'method'
Fixed this to call the super teardown_method


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_breakpad.py
File tests/custom_cluster/test_breakpad.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_breakpad.py@207
PS1, Line 207: )
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py
File tests/custom_cluster/test_executor_groups.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py@780
PS1, Line 780: e
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_executor_groups.py@852
PS1, Line 852: l
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_re2_max_mem.py
File tests/custom_cluster/test_re2_max_mem.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_re2_max_mem.py@39
PS1, Line 39: l
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_udf_concurrency.py
File tests/custom_cluster/test_udf_concurrency.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/custom_cluster/test_udf_concurrency.py@82
PS1, Line 82: e
> flake8: F841 local variable 'e' is assigned to but never used
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py
File tests/metadata/test_event_processing.py:

http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@522
PS1, Line 522: )
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@527
PS1, Line 527: )
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@597
PS1, Line 597: )
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@605
PS1, Line 605: a
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@662
PS1, Line 662: l
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@724
PS1, Line 724: n
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@727
PS1, Line 727: 9
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@743
PS1, Line 743: n
> flake8: E501 line too long (91 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@744
PS1, Line 744: i
> flake8: E501 line too long (92 > 90 characters)
Done


http://gerrit.cloudera.org:8080/#/c/24026/1/tests/metadata/test_event_processing.py@746
PS1, Line 746: 9
> flake8: E501 line too long (92 > 90 characters)
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 06:58:19 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 2:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG@8
PS2, Line 8: 
Not sure if you are aware of my patch https://gerrit.cloudera.org/#/c/23992/ which also closes connections in some cases. The two patches seem to touch different places, don't know if this was intentional.


http://gerrit.cloudera.org:8080/#/c/24026/2//COMMIT_MSG@20
PS2, Line 20: This modifies most locations using these APIs to use with-as or
            : try-finally blocks to guarantee cleanup.
I was also thinking about how to handle these, and adding a "with" everywhere seemed too noisy. Can't we collect the clients created by these functions in a list, and clean them up at the end of tests? The tests that already close these connections could be handled by adding an option "closed_by_caller=False" arg or by ensuring that double close is NOOP.

I am ok with the current solution if you prefer it, but generally I think that it is better if tests have less avoidable init/cleanup code. The "classic" pytest way would be to use fixtures to make the infrastructure needed by a test explicit, e.g "client" / "client_from_vector" / "clients_per_coord".

Another thing is that some of the tests changed don't really need to create a client IMO. Added a few comments about this in tests as potential things to clean up.


http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_external_planner.py
File tests/custom_cluster/test_external_planner.py:

http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_external_planner.py@40
PS2, Line 40:     with self.create_impala_client() as setup_client:
could use execute_query()


http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_logging.py
File tests/custom_cluster/test_logging.py:

http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_logging.py@37
PS2, Line 37:     with self.create_impala_client() as client:
            :       self.execute_query_expect_success(client, query, {'max_errors': max_errors})
could use execute_query()


http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_re2_max_mem.py
File tests/custom_cluster/test_re2_max_mem.py:

http://gerrit.cloudera.org:8080/#/c/24026/2/tests/custom_cluster/test_re2_max_mem.py@47
PS2, Line 47:               self.execute_query_expect_failure(client, query)
            :           else:
            :               self.execute_query_expect_success(client, query)
could use self.client


http://gerrit.cloudera.org:8080/#/c/24026/2/tests/metadata/test_ddl_base.py
File tests/metadata/test_ddl_base.py:

http://gerrit.cloudera.org:8080/#/c/24026/2/tests/metadata/test_ddl_base.py@62
PS2, Line 62: execute
could use self.client as pass sync_ddl as query option

note that I checked the usage of this function, and it is only used as self._create_db(unique_database) in tests that drop the unique database, which seems awkward, and sync/comment are not used


http://gerrit.cloudera.org:8080/#/c/24026/2/tests/metadata/test_event_processing.py
File tests/metadata/test_event_processing.py:

http://gerrit.cloudera.org:8080/#/c/24026/2/tests/metadata/test_event_processing.py@352
PS2, Line 352:     with self.create_impala_client_from_vector(vector) as client:
The only reason for creating a client seems to be to change some query options defined in vector - execute_query_using_vector could be used instead or execute_query(..., vector.get_value('exec_option'))



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 12:46:56 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Csaba Ringhofer, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24026

to look at the new patch set (#4).

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................

IMPALA-14776 (part 1): Auto-close manually created impala clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies those APIs to register the clients in a list and
close them during test method teardown. That should prevent
resource leaks (sockets, sessions) associated with these clients.
The clients may have been cleaned up by other means (with-as or
try-finally or a manual close), so it is heavily relying on
close() being idempotent.

The list is maintained at the instance level, and it is set in
setup_method() and freed in teardown_method(). This means that
test classes need to call ImpalaTestSuite::setup_method() and
teardown_method(). This modifies several test classes to call
the these methods appropriately.

This also means that the APIs are no longer class methods, so callers
need to call them on their instance rather than on the class
itself. This required changing a handful of locations.

ImpalaTestSuite's built-in clients use an internal API so that
they can be reused across test methods. They instead are scoped
at the class level.

Testing:
 - Ran an exhaustive job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
---
M tests/common/custom_cluster_test_suite.py
M tests/common/impala_test_suite.py
M tests/conftest.py
M tests/custom_cluster/test_blacklist.py
M tests/custom_cluster/test_breakpad.py
M tests/custom_cluster/test_parquet_max_page_header.py
M tests/custom_cluster/test_permanent_udfs.py
M tests/custom_cluster/test_query_retries.py
M tests/custom_cluster/test_redaction.py
M tests/custom_cluster/test_scratch_disk.py
M tests/metadata/test_hdfs_encryption.py
M tests/metadata/test_hdfs_permissions.py
M tests/metadata/test_load.py
M tests/query_test/test_compressed_formats.py
M tests/query_test/test_insert_permutation.py
M tests/stress/test_acid_stress.py
M tests/stress/test_update_stress.py
17 files changed, 162 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/26/24026/4
-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 2:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13126/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 07:02:17 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 1:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21761/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 07:05:55 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24026

to look at the new patch set (#5).

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................

IMPALA-14776 (part 1): Auto-close manually created impala clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies those APIs to register the clients in a list and
close them during test method teardown. That should prevent
resource leaks (sockets, sessions) associated with these clients.
The clients may have been cleaned up by other means (with-as or
try-finally or a manual close), so it is heavily relying on
close() being idempotent.

The list is maintained at the instance level, and it is set in
setup_method() and freed in teardown_method(). This means that
test classes need to call ImpalaTestSuite::setup_method() and
teardown_method(). This modifies several test classes to call
these methods appropriately.

This also means that the APIs are no longer class methods, so callers
need to call them on their instance rather than on the class
itself. This required changing a handful of locations.

ImpalaTestSuite's built-in clients use an internal API so that
they can be reused across test methods. They instead are scoped
at the class level.

Testing:
 - Ran an exhaustive job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
---
M tests/common/custom_cluster_test_suite.py
M tests/common/impala_test_suite.py
M tests/conftest.py
M tests/custom_cluster/test_blacklist.py
M tests/custom_cluster/test_breakpad.py
M tests/custom_cluster/test_parquet_max_page_header.py
M tests/custom_cluster/test_permanent_udfs.py
M tests/custom_cluster/test_query_retries.py
M tests/custom_cluster/test_redaction.py
M tests/custom_cluster/test_scratch_disk.py
M tests/metadata/test_hdfs_encryption.py
M tests/metadata/test_hdfs_permissions.py
M tests/metadata/test_load.py
M tests/query_test/test_compressed_formats.py
M tests/query_test/test_insert_permutation.py
M tests/stress/test_acid_stress.py
M tests/stress/test_update_stress.py
17 files changed, 162 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/26/24026/5
-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 5
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 5: Code-Review+2

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24026/5//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24026/5//COMMIT_MSG@28
PS5, Line 28: This means that
            : test classes need to call ImpalaTestSuite::setup_method() and
            : teardown_method(). This modifies several test classes to call
            : these methods appropriately.
I hoped that there will be no need to touch many tests,but generally I think that calling the parent's setup/teardown method is the right thing to do.


http://gerrit.cloudera.org:8080/#/c/24026/5/tests/custom_cluster/test_scratch_disk.py
File tests/custom_cluster/test_scratch_disk.py:

http://gerrit.cloudera.org:8080/#/c/24026/5/tests/custom_cluster/test_scratch_disk.py@97
PS5, Line 97: ImpalaTestSuite
Maybe it would be better to have a base class like ManualCustomCluster test that works like a custom cluster test, but skip's its setup_method/teardown_method as the tests are expected to restart the cluster themselves? This looks cleaner at the first glance, but I don't know what could it break.



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 5
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Mar 2026 12:08:34 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 3:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21796/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Thu, 26 Feb 2026 06:09:21 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................

IMPALA-14776 (part 1): Auto-close manually created impala clients

There are several APIs in ImpalaTestSuite that tests can use to
create a new client:
 - create_impala_client()
 - create_impala_client_from_vector()
 - create_client_for_nth_impalad()
If the tests don't close the client properly, pytest will report
a leak of a socket. It seems possible that this type of leak can
also result in leaving an unclosed session on the impalad. This can
trigger TestValidateMetrics.test_metrics_are_zero(), which has
been an issue since switching to pytest 6.2.5.

This modifies those APIs to register the clients in a list and
close them during test method teardown. That should prevent
resource leaks (sockets, sessions) associated with these clients.
The clients may have been cleaned up by other means (with-as or
try-finally or a manual close), so it is heavily relying on
close() being idempotent.

The list is maintained at the instance level, and it is set in
setup_method() and freed in teardown_method(). This means that
test classes need to call ImpalaTestSuite::setup_method() and
teardown_method(). This modifies several test classes to call
these methods appropriately.

This also means that the APIs are no longer class methods, so callers
need to call them on their instance rather than on the class
itself. This required changing a handful of locations.

ImpalaTestSuite's built-in clients use an internal API so that
they can be reused across test methods. They instead are scoped
at the class level.

Testing:
 - Ran an exhaustive job

Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Reviewed-on: http://gerrit.cloudera.org:8080/24026
Reviewed-by: Joe McDonnell <jo...@cloudera.com>
Tested-by: Joe McDonnell <jo...@cloudera.com>
Reviewed-by: Csaba Ringhofer <cs...@cloudera.com>
---
M tests/common/custom_cluster_test_suite.py
M tests/common/impala_test_suite.py
M tests/conftest.py
M tests/custom_cluster/test_blacklist.py
M tests/custom_cluster/test_breakpad.py
M tests/custom_cluster/test_parquet_max_page_header.py
M tests/custom_cluster/test_permanent_udfs.py
M tests/custom_cluster/test_query_retries.py
M tests/custom_cluster/test_redaction.py
M tests/custom_cluster/test_scratch_disk.py
M tests/metadata/test_hdfs_encryption.py
M tests/metadata/test_hdfs_permissions.py
M tests/metadata/test_load.py
M tests/query_test/test_compressed_formats.py
M tests/query_test/test_insert_permutation.py
M tests/stress/test_acid_stress.py
M tests/stress/test_update_stress.py
17 files changed, 162 insertions(+), 55 deletions(-)

Approvals:
  Joe McDonnell: Looks good to me, but someone else must approve; Verified
  Csaba Ringhofer: Looks good to me, approved

-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 6
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-14776 (part 1): Use context managers for manually created clients

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Use context managers for manually created clients
......................................................................


Patch Set 2:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21762/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 07:24:56 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14776 (part 1): Auto-close manually created impala clients

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/24026 )

Change subject: IMPALA-14776 (part 1): Auto-close manually created impala clients
......................................................................


Patch Set 4:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py
File tests/common/impala_test_suite.py:

http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py@276
PS3, Line 276:     # In case of custom cluster tests t
> I think that this should be an instance member, or a class member in Impala
I made this an instance member set in setup_method().


http://gerrit.cloudera.org:8080/#/c/24026/3/tests/common/impala_test_suite.py@506
PS3, Line 506:     if cls.hs2_http_client:
             :       cls.hs2_http_client.close()
> This states that closing is not always idempotent - can this be an issue fo
I haven't encountered that issue.



-- 
To view, visit http://gerrit.cloudera.org:8080/24026
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
Gerrit-Change-Number: 24026
Gerrit-PatchSet: 4
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Mon, 02 Mar 2026 20:27:38 +0000
Gerrit-HasComments: Yes