Skip to content

[FLINK-30371][Connector/JDBC] Fix the problem of JdbcOutputFormat database connection leak #5

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

EchoLee5
Copy link

Fix the problem of JdbcOutputFormat database connection leak

@boring-cyborg
Copy link

boring-cyborg bot commented Dec 13, 2022

Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html)

Copy link
Contributor

@MartijnVisser MartijnVisser left a comment

Choose a reason for hiding this comment

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

@EchoLee5 Thanks for the PR, is it possible to add a test for this?

@EchoLee5
Copy link
Author

EchoLee5 commented Dec 15, 2022

@EchoLee5 Thanks for the PR, is it possible to add a test for this?

@MartijnVisser I have added test cases, please help me review the code again, thank you.

@MartijnVisser
Copy link
Contributor

@EchoLee5 Can you please rebase and use the new testing setup?

@KevDi
Copy link

KevDi commented Jul 27, 2023

@MartijnVisser is there any update on this PR? I can also open a new PR with the fixes from @EchoLee5.

@tamirsagi
Copy link

connectionProvider is configured as final and is AutoClossable which can be used in try(connectionProvider)
which handles the closeConnection automatically.

@KevDi
Copy link

KevDi commented Dec 3, 2024

@tamirsagi Is this fix still needed? Or the one i send in? #75 ?

@tamirsagi
Copy link

tamirsagi commented Dec 3, 2024

@tamirsagi Is this fix still needed? Or the one i send in? #75 ?

if you are asking whether its still relevant, then yes. yours is similar. yet, I'd wrap connectionProvider with try after calling #flush because it's cleaner & safer. + I don't see any reason to store an exception to flushException during #close.

@KevDi
Copy link

KevDi commented Dec 3, 2024

@tamirsagi it is basicly the same fix i asked on the Jira Board and they said i should open up a new PR thats why there are two :) what exactly do you mean by wrapping it? Do you have some example code?

@tamirsagi
Copy link

tamirsagi commented Dec 3, 2024

@tamirsagi it is basicly the same fix i asked on the Jira Board and they said i should open up a new PR thats why there are two :) what exactly do you mean by wrapping it? Do you have some example code?

JdbcOutputFormat#close method add it there

try (connectionProvider) {
  if (jdbcStatementExecutor != null) {
       jdbcStatementExecutor.closeStatements();
    }
  } catch (SQLException e) {
     LOG.warn("Close JDBC writer failed.", e);
  }

@simon-paradis-jive
Copy link

Would that get eventually released in the x.y.z-1.19 series ?

After a database reboot, our Flink job took several minutes to recover from the dead connection. I think this could fix it.

Flink 1.20 has also been out for a while, will we have a -1.20 matching serie ? Would it be safe to run the -1.19 jdbc connector serie against Flink 1.20 ? For now we're staying on 1.19

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.

5 participants