Skip to content

Commit

Permalink
Revert "HBASE-22917 Proc-WAL roll fails saying someone else has alrea…
Browse files Browse the repository at this point in the history
…dy created log (#544)"

This reverts commit 538a4c5.
  • Loading branch information
saintstack committed Oct 31, 2019
1 parent e1b4a2a commit ea5c572
Showing 1 changed file with 5 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,9 @@ public void recoverLease() throws IOException {
}

// 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;
}

Expand Down Expand Up @@ -1043,9 +1042,8 @@ private boolean rollWriter() throws IOException {
}

// 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;
}

Expand Down Expand Up @@ -1102,8 +1100,7 @@ boolean rollWriter(long logId) throws IOException {
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;
}

Expand Down Expand Up @@ -1168,29 +1165,6 @@ private void closeCurrentLogStream(boolean abort) {
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
// ==========================================================================
Expand Down

0 comments on commit ea5c572

Please sign in to comment.