From bf8d1f7f40569ddc3b319bd69d72a0ca2c6a3700 Mon Sep 17 00:00:00 2001 From: XiaoYou201 <58425449+XiaoYou201@users.noreply.github.com> Date: Thu, 11 Apr 2024 21:37:06 +0800 Subject: [PATCH] [INLONG-9925][Sort] Add if statement to solve continuously printing logs (#9961) --- .../inlong/sort/jdbc/internal/JdbcBatchingOutputFormat.java | 5 ++++- .../sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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;