MartijnVisser commented on code in PR #279:
URL:
https://github.com/apache/flink-connector-jdbc/pull/279#discussion_r4787167156
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/internal/JdbcOutputFormat.java:
##########
@@ -188,20 +188,19 @@ public synchronized void flush() throws IOException {
for (int i = 0; i <= executionOptions.getMaxRetries(); i++) {
try {
+ if (i > 0) {
+ updateExecutor(!connectionProvider.isConnectionValid());
+ }
attemptFlush();
batchCount = 0;
break;
+ } catch (ClassNotFoundException e) {
+ throw new IOException("Unable to update JDBC statement
executor", e);
} catch (SQLException e) {
LOG.error("JDBC executeBatch error, retry times = {}", i, e);
if (i >= executionOptions.getMaxRetries()) {
throw new IOException(e);
}
- try {
- updateExecutor(!connectionProvider.isConnectionValid());
- } catch (Exception exception) {
- LOG.error("Attempt to update the JDBC statement executor
failed.", exception);
- throw new IOException("Unable to update JDBC statement
executor", exception);
- }
try {
Thread.sleep(1000 * i);
Review Comment:
The backoff sleeps holding the lock: with 8 retries and a 20 s
`task.cancellation.timeout`, the watchdog killed the TaskManager on cancel;
main gave up at once. Can you release the lock while backing off?
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/datastream/sink/writer/JdbcWriter.java:
##########
@@ -218,7 +218,6 @@ public void close() throws Exception {
} else {
// don't jdbcOutput.close(); as we don't want neither to flush nor
to close connection
// here
- this.jdbcOutput.checkFlushException();
Review Comment:
None of the writer or output format tests fail with `checkFlushException()`
put back. Can you add a case to `ExactlyOnceJdbcWriterTest` that closes after a
failed timed flush and checks the transaction is closed?
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/datastream/sink/writer/JdbcWriter.java:
##########
@@ -218,7 +218,6 @@ public void close() throws Exception {
} else {
// don't jdbcOutput.close(); as we don't want neither to flush nor
to close connection
// here
- this.jdbcOutput.checkFlushException();
this.jdbcTransaction.close();
Review Comment:
This branch never stops the flush timer: with a batch interval set, two
`jdbc-upsert-output-format` threads still ran 5 s after cancel. Same on main,
so that goes to FLINK-41815.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]