This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-1.0 by this push:
new a086805c36 [#8741] improvement(catalog-common): Unload common logging
in htrace. (#8778)
a086805c36 is described below
commit a086805c36265379d2c3c13908d1dd772a141247
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Oct 10 15:48:47 2025 +0800
[#8741] improvement(catalog-common): Unload common logging in htrace.
(#8778)
### What changes were proposed in this pull request?
Unloaded common logging in htrace when catalogs are about to close.
### Why are the changes needed?
We need to unload it or the class loader that loads it will not be
cleaned
Fix: #8741
### Does this PR introduce _any_ user-facing change?
N/A.
### How was this patch tested?
Test locally.
Co-authored-by: Mini Yu <[email protected]>
---
.../utils/ClassLoaderResourceCleanerUtils.java | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git
a/catalogs/catalog-common/src/main/java/org/apache/gravitino/utils/ClassLoaderResourceCleanerUtils.java
b/catalogs/catalog-common/src/main/java/org/apache/gravitino/utils/ClassLoaderResourceCleanerUtils.java
index 3601351e36..9ecece6eec 100644
---
a/catalogs/catalog-common/src/main/java/org/apache/gravitino/utils/ClassLoaderResourceCleanerUtils.java
+++
b/catalogs/catalog-common/src/main/java/org/apache/gravitino/utils/ClassLoaderResourceCleanerUtils.java
@@ -126,13 +126,13 @@ public class ClassLoaderResourceCleanerUtils {
clearThreadLocalMap(thread, classLoader);
// Close all threads that are using the FilesetCatalogOperations class
loader
if (runningWithClassLoader(thread, classLoader)) {
- LOG.info("Interrupting thread: {}", thread.getName());
+ LOG.debug("Interrupting thread: {}", thread.getName());
thread.setContextClassLoader(null);
thread.interrupt();
try {
thread.join(500);
} catch (InterruptedException e) {
- LOG.warn("Failed to join thread: {}", thread.getName(), e);
+ LOG.debug("Failed to join thread: {}", thread.getName(), e);
}
}
}
@@ -178,7 +178,7 @@ public class ClassLoaderResourceCleanerUtils {
if (value != null
&& value.getClass().getClassLoader() != null
&& value.getClass().getClassLoader() == targetClassLoader) {
- LOG.info(
+ LOG.debug(
"Cleaning up thread local {} for thread {} with custom class
loader",
value,
thread.getName());
@@ -188,7 +188,7 @@ public class ClassLoaderResourceCleanerUtils {
}
}
} catch (Exception e) {
- LOG.warn("Failed to clean up thread locals for thread {}",
thread.getName(), e);
+ LOG.debug("Failed to clean up thread locals for thread {}",
thread.getName(), e);
}
}
@@ -221,6 +221,19 @@ public class ClassLoaderResourceCleanerUtils {
*/
private static void releaseLogFactoryInCommonLogging(ClassLoader
currentClassLoader)
throws Exception {
+
+ // If we use fileset with the local file system, HTrace will be used, so
we need to
+ // release the HTrace LogFactory as well.
+ try {
+ Class<?> htraceLogFactoryClass =
+ Class.forName(
+ "org.apache.htrace.shaded.commons.logging.LogFactory", true,
currentClassLoader);
+ MethodUtils.invokeStaticMethod(htraceLogFactoryClass, "release",
currentClassLoader);
+ } catch (Exception e) {
+ // Ignore if htrace is not used
+ LOG.debug("HTrace is not used, skipping release of HTrace
LogFactory...");
+ }
+
// Release the LogFactory for the FilesetCatalogOperations class loader
Class<?> logFactoryClass =
Class.forName("org.apache.commons.logging.LogFactory", true,
currentClassLoader);
@@ -297,7 +310,7 @@ public class ClassLoaderResourceCleanerUtils {
try {
consumer.accept(value);
} catch (Exception e) {
- LOG.warn("Failed to execute consumer: ", e);
+ LOG.debug("Failed to execute consumer: ", e);
}
}
}