[#10844] fix(hive): close HiveClientFactory on pool shutdown#10854
Merged
diqiu50 merged 3 commits intoapache:mainfrom Apr 24, 2026
Merged
[#10844] fix(hive): close HiveClientFactory on pool shutdown#10854diqiu50 merged 3 commits intoapache:mainfrom
diqiu50 merged 3 commits intoapache:mainfrom
Conversation
Ensure HiveClientPool closes its HiveClientFactory after pool clients are closed, so backend HiveClientClassLoader gets explicitly closed instead of relying on GC timing. Also add a regression assertion in TestHiveClientPool and a stress script (dev/ci/hive_catalog_oom_repro.sh) that repeatedly creates/loads/drops Hive catalogs for long-run OOM reproduction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes Hive client classloader cleanup deterministic by ensuring HiveClientFactory is always closed when a HiveClientPool is shut down, and adds tooling to help reproduce long-running Hive catalog churn/metaspace issues.
Changes:
- Override
HiveClientPool#close()to callsuper.close()and then close the underlyingHiveClientFactoryin afinallyblock. - Extend
TestHiveClientPoolto assert the factory-close path is invoked. - Add a
dev/ci/hive_catalog_oom_repro.shstress script that repeatedly creates/drops Hive catalogs/schemas/tables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
dev/ci/hive_catalog_oom_repro.sh |
Adds a churn/stress repro script for long-run metaspace/OOM investigation. |
catalogs/hive-metastore-common/src/test/java/org/apache/gravitino/hive/TestHiveClientPool.java |
Adds verification that the pool’s factory-close path is executed on close. |
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/HiveClientPool.java |
Ensures HiveClientFactory (and its classloader) is closed deterministically when the pool closes. |
Code Coverage Report
Files
|
laserninja
pushed a commit
to laserninja/gravitino
that referenced
this pull request
Apr 24, 2026
…pache#10854) ### What changes were proposed in this pull request? This PR makes Hive client classloader cleanup deterministic when Hive client pools are closed. - Override `HiveClientPool#close()` to call `super.close()` and then always close `HiveClientFactory` in `finally`. - Add `TestHiveClientPool` assertion to verify factory-close path is invoked. - Add `dev/ci/hive_catalog_oom_repro.sh` stress script to repeatedly create schema/table, load table, and drop catalog for long-run metaspace/OOM reproduction. ### Why are the changes needed? `HiveClientFactory` owns `backendClassLoader` (`HiveClientClassLoader`) and only closes it in `HiveClientFactory#close()`. Previously, `HiveClientPool` only closed pooled `HiveClient` instances, so the factory close path could be skipped, making classloader cleanup depend on GC timing and causing classloader accumulation under long-running churn. Fix: apache#10844 ### Does this PR introduce _any_ user-facing change? No API changes. A new internal CI/dev stress script is added for reproduction and verification. ### How was this patch tested? - `./gradlew :catalogs:hive-metastore-common:test --tests org.apache.gravitino.hive.TestHiveClientPool --no-daemon` - `bash -n dev/ci/hive_catalog_oom_repro.sh` --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR makes Hive client classloader cleanup deterministic when Hive client pools are closed.
HiveClientPool#close()to callsuper.close()and then always closeHiveClientFactoryinfinally.TestHiveClientPoolassertion to verify factory-close path is invoked.dev/ci/hive_catalog_oom_repro.shstress script to repeatedly create schema/table, load table, and drop catalog for long-run metaspace/OOM reproduction.Why are the changes needed?
HiveClientFactoryownsbackendClassLoader(HiveClientClassLoader) and only closes it inHiveClientFactory#close().Previously,
HiveClientPoolonly closed pooledHiveClientinstances, so the factory close path could be skipped, making classloader cleanup depend on GC timing and causing classloader accumulation under long-running churn.Fix: #10844
Does this PR introduce any user-facing change?
No API changes.
A new internal CI/dev stress script is added for reproduction and verification.
How was this patch tested?
./gradlew :catalogs:hive-metastore-common:test --tests org.apache.gravitino.hive.TestHiveClientPool --no-daemonbash -n dev/ci/hive_catalog_oom_repro.sh