hudi-agent commented on code in PR #20219:
URL: https://github.com/apache/hudi/pull/20219#discussion_r4250794703
##########
hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveSyncClient.java:
##########
@@ -166,11 +169,47 @@ public HoodieHiveSyncClient(HiveSyncConfig config,
HoodieTableMetaClient metaCli
// HiveQueryDDLExecutor's own try block is even entered. Closing here
covers every
// such window; both close() methods are idempotent, so overlapping with
the
// executor's cleanup (or buildHiveQueryDDLExecutor's rollback) is
harmless.
+ // The metastore client is closed too: the caller never gets this object
to close it, and
+ // Hive would close it only if something on this thread later replaced
its cached instance.
closePartitionPoolsQuietly();
+ closeClient();
throw new HoodieHiveSyncException("Failed to create
HiveMetaStoreClient", e);
}
}
+ /**
+ * Takes the instance that owns {@link #client} out of Hive's cache for this
thread, if it is
+ * there. Hive replaces the cached instance, closing its client, when a Hive
session on the thread
+ * brings a different metastore conf, as a HiveQL-mode Driver's session does
on its first
+ * statement, by setting the metastore filter hook for authorization. Until
then the client stays
+ * cached, so that the session's teardown reuses it rather than opening a
connection of its own.
+ */
+ private void releaseClientFromHiveCache() {
+ if (threadCachingClient == Thread.currentThread()) {
+ Hive.set(null);
+ threadCachingClient = null;
+ }
+ }
+
+ /**
+ * Closes {@link #client}, which only closing it directly releases once it
is out of Hive's cache,
+ * including an underlying client that RetryingMetaStoreClient rebuilt after
a transient
+ * TException. Hive.closeCurrent() then closes whatever instance is left in
the cache.
+ */
+ private void closeClient() {
Review Comment:
🤖 nit: the Javadoc's first sentence ("which only closing it directly
releases once it is out of Hive's cache") is hard to parse. Could you split it
into two plain statements? For example: "Closes `client` directly, since Hive
no longer closes it once it is out of the cache. This also releases a client
that RetryingMetaStoreClient rebuilt."
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]