danny0405 commented on code in PR #9776:
URL: https://github.com/apache/hudi/pull/9776#discussion_r1349442374


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java:
##########
@@ -90,15 +101,25 @@ public void withOutputStream(FSDataOutputStream output) {
    */
   private FSDataOutputStream getOutputStream() throws IOException {
     if (this.output == null) {
-      Path path = logFile.getPath();
-      if (fs.exists(path)) {
-        rollOver();
-        createNewFile();
-        LOG.info("File {} already exists, rolling over to {}", path, 
logFile.getPath());
-      } else {
-        LOG.info(logFile + " does not exist. Create a new file");
-        // Block size does not matter as we will always manually autoflush
-        createNewFile();
+      boolean created = false;
+      while (!created) {
+        try {
+          // Block size does not matter as we will always manually autoflush
+          createNewFile();
+          LOG.info("Created a new log file: {}", logFile);
+          created = true;
+        } catch (FileAlreadyExistsException ignored) {
+          LOG.info("File {} already exists, rolling over", logFile.getPath());
+          rollOver();
+        } catch (RemoteException re) {
+          if 
(re.getClassName().contentEquals(AlreadyBeingCreatedException.class.getName())) 
{
+            LOG.warn("Another task executor writing to the same log file(" + 
logFile + ", rolling over");
+            // Rollover the current log file (since cannot get a stream 
handle) and create new one
+            rollOver();
+          } else {
+            throw re;

Review Comment:
   Sorry, I don't think we need a wrapper `HoodieException`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to