Skip to content

HIVE-29595: HiveClientCache does not respect metastore.client.impl#6462

Open
jlalwani-amazon wants to merge 1 commit intoapache:masterfrom
jlalwani-amazon:HIVE-12679-hcatalog-pluggable-metastore-client
Open

HIVE-29595: HiveClientCache does not respect metastore.client.impl#6462
jlalwani-amazon wants to merge 1 commit intoapache:masterfrom
jlalwani-amazon:HIVE-12679-hcatalog-pluggable-metastore-client

Conversation

@jlalwani-amazon
Copy link
Copy Markdown

@jlalwani-amazon jlalwani-amazon commented May 4, 2026

Problem

HIVE-12679 (fixed in 4.2.0) added support for pluggable IMetaStoreClient via metastore.client.impl in the main Hive path (HiveMetaStoreClientBuilder). However, HiveClientCache — used by HCatalog's HCatInputFormat/HCatOutputFormat — was not updated and still hardcodes HiveMetaStoreClient:

  1. getNonCachedHiveMetastoreClient() calls RetryingMetaStoreClient.getProxy(hiveConf, true) which hardcodes HiveMetaStoreClient.class.getName()
  2. CacheableHiveMetaStoreClient extends HiveMetaStoreClient — only works with the Thrift client

This means custom IMetaStoreClient implementations (e.g., AWS Glue Data Catalog) are ignored when accessing Hive tables through HCatalog, even though they work correctly through the main Hive path.

Fix

  1. getNonCachedHiveMetastoreClient() now reads the class name from MetastoreConf.ConfVars.METASTORE_CLIENT_IMPL and passes it to RetryingMetaStoreClient.getProxy(). Retry behavior is preserved.

  2. CacheableHiveMetaStoreClient refactored from extends HiveMetaStoreClient to implements InvocationHandler. It wraps any IMetaStoreClient via Proxy.newProxyInstance, delegating metastore calls to the underlying client while managing cache lifecycle (acquire/release/teardown).

  3. ICacheableMetaStoreClient changed from extends IMetaStoreClient to extends Closeable since the proxy handles IMetaStoreClient.

  4. invoke() unwraps InvocationTargetException so callers see the real exception.

Testing

mvn test -pl metastore -Dtest=TestHiveClientCache -Drat.skip=true -am — 5/5 pass, 0 failures.

Note to committers

I don't have Apache JIRA access to file a new ticket. Could a committer please create one (component: Metastore, HCatalog) and I'll update the PR title? This is a follow-up to HIVE-12679 which missed the HCatalog code path.

@jlalwani-amazon jlalwani-amazon changed the title HIVE-12679: Support pluggable IMetaStoreClient in HiveClientCache HIVE-29XXX: HiveClientCache ignores metastore.client.impl config (HCatalog) May 4, 2026
@jlalwani-amazon jlalwani-amazon changed the title HIVE-29XXX: HiveClientCache ignores metastore.client.impl config (HCatalog) HIVE-12679 follow-up: HiveClientCache does not respect metastore.client.impl May 4, 2026
@jlalwani-amazon jlalwani-amazon changed the title HIVE-12679 follow-up: HiveClientCache does not respect metastore.client.impl HIVE-29595: HiveClientCache does not respect metastore.client.impl May 4, 2026
HiveClientCache (used by HCatalog's HCatInputFormat/HCatOutputFormat)
hardcodes HiveMetaStoreClient, ignoring the metastore.client.impl
config. This means any custom IMetaStoreClient implementation
configured via hive.metastore.client.impl is not used when accessing
Hive tables through HCatalog.

This patch makes HiveClientCache respect the configured metastore
client implementation by:

1. getNonCachedHiveMetastoreClient() now reads the class name from
   MetastoreConf.ConfVars.METASTORE_CLIENT_IMPL and passes it to
   RetryingMetaStoreClient.getProxy(). Previously hardcoded to
   HiveMetaStoreClient.

2. CacheableHiveMetaStoreClient refactored from
   'extends HiveMetaStoreClient' to 'implements InvocationHandler'.
   It now wraps any IMetaStoreClient via Proxy.newProxyInstance,
   delegating metastore calls to the underlying client while managing
   cache lifecycle (acquire/release/teardown).

3. ICacheableMetaStoreClient changed from 'extends IMetaStoreClient'
   to 'extends Closeable' since the proxy handles IMetaStoreClient.

4. getOrCreate() creates the client via getNonCachedHiveMetastoreClient
   and wraps it in the proxy.

5. invoke() unwraps InvocationTargetException so callers see the real
   exception rather than a reflection wrapper.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants