mirror of https://github.com/apache/nifi.git
NIFI-841: Ensure that IOExceptions on session commit are handled properly
Signed-off-by: joewitt <joewitt@apache.org> Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
parent
a264c49d80
commit
35439db347
|
@ -292,9 +292,10 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
private void commit(final Checkpoint checkpoint) {
|
private void commit(final Checkpoint checkpoint) {
|
||||||
|
try {
|
||||||
final long commitStartNanos = System.nanoTime();
|
final long commitStartNanos = System.nanoTime();
|
||||||
|
|
||||||
resetWriteClaims();
|
resetWriteClaims(false);
|
||||||
resetReadClaim();
|
resetReadClaim();
|
||||||
|
|
||||||
final long updateProvenanceStart = System.nanoTime();
|
final long updateProvenanceStart = System.nanoTime();
|
||||||
|
@ -424,6 +425,15 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
|
||||||
|
|
||||||
LOG.debug(timingInfo.toString());
|
LOG.debug(timingInfo.toString());
|
||||||
}
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
try {
|
||||||
|
rollback();
|
||||||
|
} catch (final Exception e1) {
|
||||||
|
e.addSuppressed(e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEventRepository(final Checkpoint checkpoint) {
|
private void updateEventRepository(final Checkpoint checkpoint) {
|
||||||
|
@ -2115,23 +2125,40 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetWriteClaims() {
|
private void resetWriteClaims() {
|
||||||
|
resetWriteClaims(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetWriteClaims(final boolean suppressExceptions) {
|
||||||
try {
|
try {
|
||||||
if (currentWriteClaimStream != null) {
|
if (currentWriteClaimStream != null) {
|
||||||
|
try {
|
||||||
currentWriteClaimStream.flush();
|
currentWriteClaimStream.flush();
|
||||||
|
} finally {
|
||||||
currentWriteClaimStream.close();
|
currentWriteClaimStream.close();
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
|
||||||
}
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
if (!suppressExceptions) {
|
||||||
|
throw new FlowFileAccessException("Unable to flush the output of FlowFile to the Content Repository");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentWriteClaimStream = null;
|
currentWriteClaimStream = null;
|
||||||
currentWriteClaim = null;
|
currentWriteClaim = null;
|
||||||
currentWriteClaimFlowFileCount = 0;
|
currentWriteClaimFlowFileCount = 0;
|
||||||
currentWriteClaimSize = 0L;
|
currentWriteClaimSize = 0L;
|
||||||
|
|
||||||
for (final ByteCountingOutputStream out : appendableStreams.values()) {
|
for (final ByteCountingOutputStream out : appendableStreams.values()) {
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
out.flush();
|
out.flush();
|
||||||
|
} finally {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (final Exception e) {
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
if (!suppressExceptions) {
|
||||||
|
throw new FlowFileAccessException("Unable to flush the output of FlowFile to the Content Repository");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
appendableStreams.clear();
|
appendableStreams.clear();
|
||||||
|
|
Loading…
Reference in New Issue