Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve][Zeta] Add classloader cache mode to fix metaspace leak #6355

Merged
merged 6 commits into from
Feb 27, 2024

Conversation

Hisoka-X
Copy link
Member

Purpose of this pull request

This PR try to do two thing.

  1. Reduce the classloader number when submit job. Before this PR, each parallelism with create one classloader. After this PR, it will reuse only one classloader if it job id and jar path as both same by default.
  2. Add new config classloader-cache-mode in seatunnel.yaml. This config is mainly to solve the leakage problem of classloader due to the failure of static thread to be destroyed normally. Through this configuration, all different jobs but using the same jar path will reuse the same classloader to reduce the creation and leakage of static threads.

Does this PR introduce any user-facing change?

no

How was this patch tested?

add new test.

Check list

@Hisoka-X Hisoka-X changed the title [Improve] Add classloader cache mode to fix metaspace leak [Improve][Zeta] Add classloader cache mode to fix metaspace leak Feb 19, 2024
Comment on lines +53 to +66
public void testFakeSourceToInMemorySink() throws IOException, InterruptedException {
LOG.info("test classloader with cache mode: {}", cacheMode());
for (int i = 0; i < 10; i++) {
// load in memory sink which already leak thread with classloader
Container.ExecResult execResult = executeJob(server, CONF_FILE);
Assertions.assertEquals(0, execResult.getExitCode());
Assertions.assertTrue(containsDaemonThread());
if (cacheMode()) {
Assertions.assertEquals(3, getClassLoaderCount());
} else {
Assertions.assertEquals(2 + i, getClassLoaderCount());
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference of cache mode enable or disable.

liugddx
liugddx previously approved these changes Feb 19, 2024
Copy link
Member

@liugddx liugddx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! LGTM

Copy link
Contributor

@TaoZex TaoZex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feature!

liugddx
liugddx previously approved these changes Feb 22, 2024
Copy link
Member

@liugddx liugddx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hisoka-X
Copy link
Member Author

waiting #6356

# Conflicts:
#	seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java
Copy link
Member

@liugddx liugddx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [zeta] java.lang.OutOfMemoryError: Metaspace
4 participants