pankaj72981 commented on a change in pull request #544: HBASE-22917 Proc-WAL 
roll fails saying someone else has already created log
URL: https://github.com/apache/hbase/pull/544#discussion_r326845784
 
 

 ##########
 File path: 
hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java
 ##########
 @@ -1100,7 +1100,25 @@ boolean rollWriter(long logId) throws IOException {
       startPos = newStream.getPos();
     } catch (IOException ioe) {
       LOG.warn("Encountered exception writing header", ioe);
-      newStream.close();
+      try {
+        newStream.close();
+      } catch (IOException e) {
+        LOG.error("Exception occured while closing the file {}", newLogFile, 
e);
+      }
+      try {
+        // Delete the incomplete file
+        if (!fs.delete(newLogFile, false)) {
+          LOG.warn(
+            "Failed to delete the log file {}, increasing the log id by 1 for 
the next roll attempt",
+            newLogFile);
+          flushLogId++;
+        }
+      } catch (IOException e) {
+        LOG.warn("Exception occured while deleting the file {}", newLogFile, 
e);
+        flushLogId++;
+        LOG.info("Increased the log id to {}", flushLogId);
+      }
+
 
 Review comment:
   > I think I said this would be easier to read if out in a standalone method.
   
   Yeah, will do it on another commit.
   
   > And yeah, the close and delete would be the wrong thing to do if this is a 
dead server but doesn't know it yet (and another has taken over WAL writing).
   
   IIRC two master can't write proc-WAL together, do we have such corner 
scenario? 
   However here we are trying to cleanup when rollWriter fails when write 
header throws IOE.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to