apache / beam

Apache Beam is a unified programming model for Batch and Streaming data processing.
https://beam.apache.org/
Apache License 2.0
7.9k stars 4.27k forks source link

[Bug]: JdbcDriver causes metaspace leak #29494

Open gabrywu opened 1 year ago

gabrywu commented 1 year ago

What happened?

As of now ,org.apache.beam.sdk.extensions.sql.impl.JdbcDriver doesn't de-register itself from java.sql.DriverManager. And this can causes metaspace leak, because it holds a ChildFirstClassLoader on a flink runner. If we submit jobs many times to a same flink cluster, corresponding cluster OOM eventually.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

gabrywu commented 1 year ago

@Abacn can you help with this one?

Abacn commented 1 year ago

JdbcDriver extends from calcite Driver, and both JdbcDriver and its base class calls register at static statement. Are they both contribute to metaspace leak? I do not find an obvious solution either here.

Are you able to deregister the stall Drivers using DriverManager.Deregister in a DoFn after Impulse() (so it will execute once) or its lacking permission (raising SQL SecurityException) ?

gabrywu commented 1 year ago

@Abacn yes, I remove this Driver by DriverManager.deregister in a tearDown, and it's OK to run DriverManager.deregister multiple times