HBASE-14234 Exception encountered in WALProcedureStore#rollWriter() should be properly handled

This commit is contained in:
tedyu 2015-08-18 09:01:19 -07:00
parent c9b3d837a0
commit 354255340a
1 changed files with 13 additions and 3 deletions

View File

@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.procedure2.util.ByteSlot;
import org.apache.hadoop.hbase.procedure2.util.StringUtils;
import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureWALHeader;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.ipc.RemoteException;
import com.google.common.annotations.VisibleForTesting;
@ -681,14 +682,23 @@ public class WALProcedureStore extends ProcedureStoreBase {
FSDataOutputStream newStream = null;
Path newLogFile = null;
long startPos = -1;
newLogFile = getLogFilePath(logId);
try {
newLogFile = getLogFilePath(logId);
newStream = fs.create(newLogFile, false);
ProcedureWALFormat.writeHeader(newStream, header);
startPos = newStream.getPos();
} catch (FileAlreadyExistsException e) {
LOG.error("Log file with id=" + logId + " already exists", e);
return false;
} catch (RemoteException re) {
LOG.warn("failed to create log file with id=" + logId, re);
return false;
}
try {
ProcedureWALFormat.writeHeader(newStream, header);
startPos = newStream.getPos();
} catch (IOException ioe) {
LOG.warn("Encountered exception writing header", ioe);
newStream.close();
return false;
}
lock.lock();
try {