Martijn Visser created FLINK-41793:
--------------------------------------
Summary: At-least-once JdbcWriter leaks its connection if opening
fails
Key: FLINK-41793
URL: https://issues.apache.org/jira/browse/FLINK-41793
Project: Flink
Issue Type: Bug
Components: Connectors / JDBC
Affects Versions: jdbc-5.0.0, jdbc-4.1.1, jdbc-3.5.0
Reporter: Martijn Visser
The at-least-once {{JdbcWriter}} opens its {{JdbcOutputFormat}} as the last
step of its constructor. If {{prepareStatements()}} fails after the connection
was established, the constructor throws with the connection still open.
{{SinkWriterOperator}} only keeps a writer once {{createWriter()}} returns, so
nothing calls {{close()}}, and each restart leaks another connection. On Derby
an insert into a missing table shows it: after {{unable to open JDBC writer}}
the provider's connection is still open. PostgreSQL and MySQL Connector/J
prepare on execute by default, so there the same mistake only fails at the
first flush.
{{JdbcOutputFormat.close()}} works on a half-open format, so we should close it
when {{open()}} fails. The {{JdbcWriter}} of FLINK-37987 already does; the v4.1
and v3.4 branches need the fix on their own.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)