yuqi1129 commented on issue #11301:
URL: https://github.com/apache/gravitino/issues/11301#issuecomment-4620860459

   > The assumption that MutableQuantiles.scheduler belongs to the catalog's 
ClassLoader is incorrect. The class may be loaded by a parent ClassLoader (or 
the system ClassLoader), and the static field is shared across the entire JVM.
   
   The class `MutableQuantiles` should be included in `hadoop-common.jar`,  
`hadoop-client-api.jar` or `paimon-{s3,oss}.jar`, those jars should not be in 
the `AppClassLoader` which loads files in `${GRAVITINO_HOME}/libs`, so I'm not 
very clear about why `scheduler` is a JVM-global static resource as it's loaded 
by `IsolatedClassLoader` that is specified for Iceberg catalogs. 
   
   Anyway, I believe we need to add the following check to avoid problems like 
this one.
   
   ```java
   
     Class<?> mutableQuantilesClass =
         Class.forName("org.apache.hadoop.metrics2.lib.MutableQuantiles", true, 
targetClassLoader);
   
     // Only shut down the scheduler if MutableQuantiles was loaded by 
targetClassLoader itself.
     // If it was delegated to AppClassLoader/parent (shared deployment), 
shutting it down
     // would break metrics globally for the entire JVM.
     if (mutableQuantilesClass.getClassLoader() == targetClassLoader) {
         ScheduledExecutorService scheduler =
             (ScheduledExecutorService)
                 FieldUtils.readStaticField(mutableQuantilesClass, "scheduler", 
true);
         scheduler.shutdownNow();
     }
   ```
   


-- 
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]

Reply via email to