mirror of https://github.com/apache/nifi.git
NIFI-902: Ensure that if we get an IOException during rollover of WAL, we are able to recover
This commit is contained in:
parent
76b5b38cc4
commit
5de37f63d9
|
@ -722,11 +722,20 @@ public final class MinimalLockingWriteAheadLog<T> implements WriteAheadRepositor
|
|||
try {
|
||||
final DataOutputStream out = dataOut;
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (final IOException ioe) {
|
||||
dataOut = null;
|
||||
fileOut = null;
|
||||
|
||||
blackList();
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
final Path editPath = getNewEditPath();
|
||||
final FileOutputStream fos = new FileOutputStream(editPath.toFile());
|
||||
try {
|
||||
final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos));
|
||||
outStream.writeUTF(MinimalLockingWriteAheadLog.class.getName());
|
||||
outStream.writeInt(writeAheadLogVersion);
|
||||
|
@ -735,6 +744,19 @@ public final class MinimalLockingWriteAheadLog<T> implements WriteAheadRepositor
|
|||
outStream.flush();
|
||||
dataOut = outStream;
|
||||
fileOut = fos;
|
||||
} catch (final IOException ioe) {
|
||||
logger.error("Failed to create new journal for {} due to {}", new Object[] {this, ioe.toString()}, ioe);
|
||||
try {
|
||||
fos.close();
|
||||
} catch (final IOException innerIOE) {
|
||||
}
|
||||
|
||||
dataOut = null;
|
||||
fileOut = null;
|
||||
blackList();
|
||||
|
||||
throw ioe;
|
||||
}
|
||||
|
||||
currentJournalFilename = editPath.toFile().getName();
|
||||
|
||||
|
|
|
@ -159,7 +159,18 @@ public class ContinuallyRunProcessorTask implements Callable<Boolean> {
|
|||
} finally {
|
||||
try {
|
||||
if (batch) {
|
||||
try {
|
||||
rawSession.commit();
|
||||
} catch (final Exception e) {
|
||||
final ProcessorLog procLog = new SimpleProcessLogger(procNode.getIdentifier(), procNode.getProcessor());
|
||||
procLog.error("Failed to commit session {} due to {}; rolling back", new Object[] { rawSession, e.toString() }, e);
|
||||
|
||||
try {
|
||||
rawSession.rollback(true);
|
||||
} catch (final Exception e1) {
|
||||
procLog.error("Failed to roll back session {} due to {}", new Object[] { rawSession, e.toString() }, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final long processingNanos = System.nanoTime() - startNanos;
|
||||
|
|
|
@ -32,11 +32,14 @@ import org.apache.nifi.controller.scheduling.ProcessContextFactory;
|
|||
import org.apache.nifi.groups.ProcessGroup;
|
||||
import org.apache.nifi.groups.RemoteProcessGroup;
|
||||
import org.apache.nifi.util.FormatUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This task runs through all Connectable Components and goes through its incoming queues, polling for FlowFiles and accepting none. This causes the desired side effect of expiring old FlowFiles.
|
||||
*/
|
||||
public class ExpireFlowFiles implements Runnable {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExpireFlowFiles.class);
|
||||
|
||||
private final FlowController flowController;
|
||||
private final ProcessContextFactory contextFactory;
|
||||
|
@ -49,7 +52,11 @@ public class ExpireFlowFiles implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
|
||||
try {
|
||||
expireFlowFiles(rootGroup);
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to expire FlowFiles due to {}", e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private StandardProcessSession createSession(final Connectable connectable) {
|
||||
|
|
Loading…
Reference in New Issue