错误日志:
An I/O error occurred while sending to the backend. Call getNextException to see other errors in the batch. at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:170) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:578) at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:905) at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:928) at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1685) at org.apache.flink.connector.jdbc.internal.executor.SimpleBatchStatementExecutor.executeBatch(SimpleBatchStatementExecutor.java:73) at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.attemptFlush(JdbcOutputFormat.java:248) at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:218) at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.lambda$open$0(JdbcOutputFormat.java:157) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:579) ... 14 common frames omitted Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:161) at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:128) at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:113) at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73) at org.postgresql.core.PGStream.receiveChar(PGStream.java:465) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2154) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:573) ... 14 common frames omitted
错误原因: PostgreSQL 貌似连接默认只会保留半个小时,超过了半个小时就会断开连接,导致超时 解决方案: 可以自己在代码中维护一个连接池,然后配置些连接的保活和探测等动作,比如使用HikariCP等这种类似的 连接池组件
