Skip to content

Conversation

@joeyutong
Copy link
Contributor

What changes were proposed in this pull request?

This PR performs actual resource cleanup in HiveClientPool.close

Why are the changes needed?

Any code path in the current implementation that close the pool via ClientPoolImpl.close() will cause the connection leaks because the HiveClientPool.close is a no-op.

Fix: #9581

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Add UTs.

@joeyutong
Copy link
Contributor Author

CC @diqiu50

@jerryshao jerryshao requested a review from diqiu50 January 6, 2026 03:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a resource leak issue in HiveClientPool where the close() method was a no-op, preventing proper cleanup of Hive Metastore client connections. The fix ensures that when the pool is closed, the underlying client resources are properly released by calling client.close().

Key Changes

  • Added client.close() call in HiveClientPool.close() to perform actual resource cleanup
  • Updated comments to clarify that reconnect is handled by RetryingMetaStoreClient rather than the pool
  • Added comprehensive unit tests to verify the close behavior and prevent regression

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/HiveClientPool.java Fixed the close method to call client.close() and improved comments explaining the no-op reconnect behavior
catalogs/hive-metastore-common/src/test/java/org/apache/gravitino/hive/TestHiveClientPool.java Added unit tests covering client creation failures, reconnect behavior, and close verification
catalogs/hive-metastore-common/build.gradle.kts Added mockito-core test dependency for mocking in unit tests

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using static imports for Mockito methods to improve readability and align with the project's conventions. Most test files in the codebase use static imports like import static org.mockito.Mockito.mock;, import static org.mockito.Mockito.spy;, etc., instead of using Mockito. prefix throughout the test class.

Copilot uses AI. Check for mistakes.
diqiu50
diqiu50 previously approved these changes Jan 6, 2026
@diqiu50 diqiu50 self-requested a review January 6, 2026 04:00
@diqiu50 diqiu50 dismissed their stale review January 6, 2026 04:00

missing select approve

@diqiu50 diqiu50 merged commit 93bdc3b into apache:main Jan 12, 2026
26 checks passed
@jerqi
Copy link
Contributor

jerqi commented Jan 12, 2026

@diqiu50 Do u think that we should back port this pull request to branch 1.1?

@diqiu50
Copy link
Contributor

diqiu50 commented Jan 13, 2026

@diqiu50 Do u think that we should back port this pull request to branch 1.1?

Yes, I think so.
@joeyutong Can you create a PR to back port this to the branch 1.1

@joeyutong
Copy link
Contributor Author

@diqiu50 Sure,I will follow up

joeyutong added a commit to joeyutong/gravitino that referenced this pull request Jan 14, 2026
…lose (apache#9617)

<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
   Examples:
     - "[apache#123] feat(operator): support xxx"
     - "[apache#233] fix: check null before access result in xxx"
     - "[MINOR] refactor: fix typo in variable name"
     - "[MINOR] docs: fix typo in README"
     - "[apache#255] test: fix flaky test NameOfTheTest"
   Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->

### What changes were proposed in this pull request?

This PR performs actual resource cleanup in `HiveClientPool.close`

### Why are the changes needed?

Any code path in the current implementation that close the pool via
`ClientPoolImpl.close()` will cause the connection leaks because the
HiveClientPool.close is a no-op.

Fix: apache#9581

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Add UTs.
@joeyutong joeyutong deleted the hive_client_pool branch January 14, 2026 09:16
jerqi pushed a commit that referenced this pull request Jan 14, 2026
…ol close (#9712)

### What changes were proposed in this pull request?

This PR backports #9617 to branch 1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: close() does not perform resource cleanup anymore

3 participants