diff --git a/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcBatchingOutputFormat.java b/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcBatchingOutputFormat.java index 7b3b1db4f15..dc96bb6ae3a 100644 --- a/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcBatchingOutputFormat.java +++ b/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcBatchingOutputFormat.java @@ -355,8 +355,11 @@ public void initializeState(FunctionInitializationContext context) throws Except @Override public synchronized void flush() throws IOException { + // when batch count > 0, execute flush operation + if (batchCount == 0) { + return; + } checkFlushException(); - for (int i = 0; i <= executionOptions.getMaxRetries(); i++) { try { attemptFlush(); diff --git a/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java b/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java index 467522ee22b..47fe13aa909 100644 --- a/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java +++ b/inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java @@ -608,6 +608,10 @@ public void initializeState(FunctionInitializationContext context) throws Except @Override public synchronized void flush() throws IOException { + // when batch count > 0, execute flush operation + if (batchCount == 0) { + return; + } checkFlushException(); attemptFlush(); batchCount = 0;