From ea5c572963727888a1ca137f9871081918086977 Mon Sep 17 00:00:00 2001 From: stack Date: Thu, 31 Oct 2019 08:10:34 -0700 Subject: [PATCH] Revert "HBASE-22917 Proc-WAL roll fails saying someone else has already created log (#544)" This reverts commit 538a4c51ff8464f57e26cc22f9c559c1a30b5864. --- .../store/wal/WALProcedureStore.java | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java index 298148317ed..a865a095c24 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java @@ -421,10 +421,9 @@ public class WALProcedureStore extends ProcedureStoreBase { } // Create new state-log - long newFlushLogId = flushLogId + 1; - if (!rollWriter(newFlushLogId)) { + if (!rollWriter(flushLogId + 1)) { // someone else has already created this log - LOG.debug("Someone else has already created log {}. Retrying.", newFlushLogId); + LOG.debug("Someone else has already created log {}. Retrying.", flushLogId); continue; } @@ -1043,9 +1042,8 @@ public class WALProcedureStore extends ProcedureStoreBase { } // Create new state-log - long newFlushLogId = flushLogId + 1; - if (!rollWriter(newFlushLogId)) { - LOG.warn("someone else has already created log {}", newFlushLogId); + if (!rollWriter(flushLogId + 1)) { + LOG.warn("someone else has already created log {}", flushLogId); return false; } @@ -1102,8 +1100,7 @@ public class WALProcedureStore extends ProcedureStoreBase { startPos = newStream.getPos(); } catch (IOException ioe) { LOG.warn("Encountered exception writing header", ioe); - // Close and delete the incomplete file - closeAndDeleteIncompleteFile(newStream, newLogFile); + newStream.close(); return false; } @@ -1168,29 +1165,6 @@ public class WALProcedureStore extends ProcedureStoreBase { stream = null; } - private void closeAndDeleteIncompleteFile(FSDataOutputStream newStream, Path newLogFile) { - // Close the FS - try { - newStream.close(); - } catch (IOException e) { - LOG.error("Exception occured while closing the file {}", newLogFile, e); - } - - // Delete the incomplete file - try { - 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); - } - } - // ========================================================================== // Log Files cleaner helpers // ==========================================================================