QiuYucheng2003 opened a new issue, #12064:
URL: https://github.com/apache/inlong/issues/12064

   ### What happened
   
   Context: 
   The org.apache.inlong.audit.sink.PulsarSink class maintains a private static 
ScheduledExecutorService that is initialized in a static {} block.
   
   Problem:
   1. ClassLoader Leak (NT Defect): The static thread pool 
(pulsarPerformance-Printer-thread) is started immediately upon class loading 
and holds a strong reference to the ClassLoader. In containerized or plugin 
environments (like Flume/Agent), this prevents the ClassLoader from being 
garbage collected during hot-redeployments, leading to Metaspace OOM.
   
   2. Shared State Corruption: Since the executor is static (global), calling 
stop() on any single PulsarSink instance shuts down this shared executor. This 
unintentionally kills the performance metric task for all other running 
PulsarSink instances.
   
   ### What you expected to happen
   
   1. Instance Isolation: The ScheduledExecutorService should be an instance 
variable, not static.
   
   2. Lifecycle Management: The thread pool should be initialized in the 
start() method and shut down in the stop() method, ensuring it follows the 
lifecycle of the specific PulsarSink instance without affecting others.
   
   ### How to reproduce
   
   1. Check the source code in org.apache.inlong.audit.sink.PulsarSink.java.
   
   Line 129: private static ScheduledExecutorService scheduledExecutorService 
...
   
   Line 135 (Static Block): scheduledExecutorService.scheduleWithFixedDelay(...)
   
   2. Deploy InLong Audit with multiple PulsarSink configurations.
   
   3. Stop one sink instance.
   
   4. Result: The pulsarPerformance-Printer-thread is terminated globally, 
causing other sinks to stop reporting metrics.
   
   ### Environment
   
   MacOS 13.0
   JDK 1.8
   
   ### InLong version
   
   master
   
   ### InLong Component
   
   InLong Audit
   
   ### Are you willing to submit PR?
   
   - [x] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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