[ https://issues.apache.org/jira/browse/FLINK-30387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17646965#comment-17646965 ]
James Z.M. Gao commented on FLINK-30387: ---------------------------------------- The class containing the static fields may loaded by the TM CL, not the user CL, so the static fields may introduce side effects across jobs on some TMs. In addition, the order of release hooks of each job's _static_ field is also not easy to handle. So it is better to improve or provide some APIs, so that we can handle these concerns correctly. > support job singleton within TM > ------------------------------- > > Key: FLINK-30387 > URL: https://issues.apache.org/jira/browse/FLINK-30387 > Project: Flink > Issue Type: New Feature > Components: API / Core > Reporter: James Z.M. Gao > Priority: Major > > For better managing some shared objects between slots of the same job, such > as thread pool, db connections, cache data, etc., we need the ability to > create these objects once for each job at the beginning, then to release the > bounded resource when the job finished some how with correct order. A simple > static filed cannot always archive this when the class is loaded by the TM > classloader. > To implement this job level singleton, we can use the flink user classloader. > Since each flink job has its own context class loader, we could add some > methods to operate the user CL to create a user specify AutoCloseable object > only once for each job and close it at last in release hook of the user CL. -- This message was sent by Atlassian Jira (v8.20.10#820010)