[ 
https://issues.apache.org/jira/browse/FLINK-27621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17537317#comment-17537317
 ] 

Shengkai Fang commented on FLINK-27621:
---------------------------------------

I am +1 for this feature. Let me share some thoughs about this.

In many cases, we need add jar or remove jar for the user classloader in the 
interactive gateway.  For example,  user can

```
Flink SQL> ADD JAR 'path'; -- path to 

Flink SQL> SELECT udf(field) from mytable; -- SUBMIT the job 

Flink SQL >  ADD JAR 'path_to_connector'

Flink SQL > INSERT INTO sink_in_added_jar SELECT  udf(field) from mytable;
```
But currently we just create a new classloader when the user add jar or remove 
jar in the SQL Client side. However, create a new classloader doesn't mean the 
classes that are loaded by the old classloader will be collected.  Actually 
unloading the classes is not an easy work. It requires no one refers to the 
classes that loaded by the old classloader.  However, it relies on the usage 
and dependencies. For example, one class(e.g. Hadoop Configuration) is loaded 
by the app classloader and it caches the class(e.g. connector class) loaded by 
the child classloader. If the cache is not cleared, the old classloader can not 
be collected.

With this feature, we are able to reuse the classloader per session and reduce 
the possiblities of the OOM.



> expose SafetyNetWrapperClassLoader from private to public and add addUrl 
> method for flink client
> ------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-27621
>                 URL: https://issues.apache.org/jira/browse/FLINK-27621
>             Project: Flink
>          Issue Type: Improvement
>          Components: Runtime / Task
>    Affects Versions: 1.16.0
>            Reporter: jackylau
>            Priority: Major
>             Fix For: 1.16.0
>
>
> expose SafetyNetWrapperClassLoader from private to public and add addUrl 
> method for flink client when user need dynamic add jars



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to