You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by fo...@apache.org on 2023/01/04 03:32:14 UTC

[hudi] 04/45: fix the bug, log file will not roll over to a new file

This is an automated email from the ASF dual-hosted git repository.

forwardxu pushed a commit to branch release-0.12.1
in repository https://gitbox.apache.org/repos/asf/hudi.git

commit ab5b4fa780c12b781509e44f88f7d849a5467e89
Author: XuQianJin-Stars <fo...@apache.com>
AuthorDate: Mon Jun 20 10:21:45 2022 +0800

    fix the bug, log file will not roll over to a new file
---
 .../org/apache/hudi/common/table/log/HoodieLogFormatWriter.java  | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java b/hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java
index 8dbe85efd1..60c124784a 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java
@@ -94,7 +94,8 @@ public class HoodieLogFormatWriter implements HoodieLogFormat.Writer {
       Path path = logFile.getPath();
       if (fs.exists(path)) {
         boolean isAppendSupported = StorageSchemes.isAppendSupported(fs.getScheme());
-        if (isAppendSupported) {
+        boolean needRollOverToNewFile = fs.getFileStatus(path).getLen() > sizeThreshold;
+        if (isAppendSupported && !needRollOverToNewFile) {
           LOG.info(logFile + " exists. Appending to existing file");
           try {
             // open the path for append and record the offset
@@ -116,10 +117,12 @@ public class HoodieLogFormatWriter implements HoodieLogFormat.Writer {
             }
           }
         }
-        if (!isAppendSupported) {
+        if (!isAppendSupported || needRollOverToNewFile) {
           rollOver();
           createNewFile();
-          LOG.info("Append not supported.. Rolling over to " + logFile);
+          if (isAppendSupported && needRollOverToNewFile) {
+            LOG.info(String.format("current Log file size > %s roll over to a new log file", sizeThreshold));
+          }
         }
       } else {
         LOG.info(logFile + " does not exist. Create a new file");