JdbcBatchingOutputFormat:
for (int i = 0; i <= executionOptions.getMaxRetries(); i++) {
try {
      attemptFlush();
batchCount = 0;
      break;
} catch (SQLException e) {
LOG.error("JDBC executeBatch error, retry times = {}", i, e);
      if (i >= executionOptions.getMaxRetries()) {
throw new IOException(e);
}
try {
if (!connection.isValid(CONNECTION_CHECK_TIMEOUT_SECONDS)) {
connection = connectionProvider.reestablishConnection();
jdbcStatementExecutor.closeStatements();
jdbcStatementExecutor.prepareStatements(connection);
}
      } catch (Exception excpetion) {
LOG.error("JDBC connection is not valid, and reestablish connection failed.", 
excpetion);
         throw new IOException("Reestablish JDBC connection failed", excpetion);
}
try {
         Thread.sleep(1000 * i);
} catch (InterruptedException ex) {
         Thread.currentThread().interrupt();
         throw new IOException("unable to flush; interrupted while doing 
another attempt", e);
}
   }
}

嗯,看起来是这样的。

 if (i >= executionOptions.getMaxRetries()) {
throw new IOException(e);
}这个判断重试的代码应该放在sleep 后面。不然,Caused by: java.io.IOException: 
java.sql.SQLException: No operations allowed after statement closed. 就没机会重建连接了。



在 2020-12-03 10:36:28,"yanzi" <andyh...@126.com> 写道:
>使用flinksql 1.11版本,运行计算好的指标落入mysql,长时间没有数据会报错,导致任务会失败。
>针对:https://issues.apache.org/jira/browse/FLINK-16681,已经修复此问题,但是我们使用1.11最新版本,运行一段时间后,发现还是会有此问题,如何解决
>
>
>
>--
>Sent from: http://apache-flink.147419.n8.nabble.com/

回复