- 问题描述
- jira issue&pr
- 解决方案
Flink任务频繁重启时很容易报出metaspace OOM,经过查找发现Flink不会在不同的作业提交中重用类加载器。如果您提交一个作业(即使它是与前一个作业相同的用户代码),那么Flink将把它视为一个新作业,并为其创建一个新的类装入器。换句话说,如果您的用户代码中有类泄漏,或者任务频繁重启,那么您可以通过多次向Flink集群提交相同的作业来关闭Flink集群,这最终会耗尽元空间。
Flink在1.11.0修复了这个问题,下面为jira issue翻译和pr的代码分析。
https://issues.apache.org/jira/browse/Flink-16408
https://github.com/apache/flink/pull/11963
This PR binds the user code class loader to the lifetime of a JobTable.Job on the TaskExecutor. This means that the TaskExecutor will not release the user code class loader as long as it contains an allocated slot for the respective job. Th



