You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ij...@apache.org on 2019/09/13 00:03:13 UTC

[nifi] branch master updated: NIFI-6613: If LengthDelimitedJournal gets poisoned, log the reason and hold onto it so that it can be included as the cause of subsequent Exceptions that are thrown

This is an automated email from the ASF dual-hosted git repository.

ijokarumawak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 6b17c4b  NIFI-6613: If LengthDelimitedJournal gets poisoned, log the reason and hold onto it so that it can be included as the cause of subsequent Exceptions that are thrown
6b17c4b is described below

commit 6b17c4b1347d91177bdece540b3485e962e30a2b
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Tue Sep 3 19:05:00 2019 -0400

    NIFI-6613: If LengthDelimitedJournal gets poisoned, log the reason and hold onto it so that it can be included as the cause of subsequent Exceptions that are thrown
    
    This closes #3704.
    
    Signed-off-by: Koji Kawamura <ij...@apache.org>
---
 .../org/apache/nifi/wali/LengthDelimitedJournal.java | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/nifi-commons/nifi-write-ahead-log/src/main/java/org/apache/nifi/wali/LengthDelimitedJournal.java b/nifi-commons/nifi-write-ahead-log/src/main/java/org/apache/nifi/wali/LengthDelimitedJournal.java
index e0dcb63..c3ed0b5 100644
--- a/nifi-commons/nifi-write-ahead-log/src/main/java/org/apache/nifi/wali/LengthDelimitedJournal.java
+++ b/nifi-commons/nifi-write-ahead-log/src/main/java/org/apache/nifi/wali/LengthDelimitedJournal.java
@@ -74,7 +74,7 @@ public class LengthDelimitedJournal<T> implements WriteAheadJournal<T> {
     private int transactionCount;
     private boolean headerWritten = false;
 
-    private volatile boolean poisoned = false;
+    private volatile Throwable poisonCause = null;
     private volatile boolean closed = false;
     private final ByteBuffer transactionPreamble = ByteBuffer.allocate(12); // guarded by synchronized block
 
@@ -142,7 +142,11 @@ public class LengthDelimitedJournal<T> implements WriteAheadJournal<T> {
 
     @Override
     public synchronized boolean isHealthy() {
-        return !closed && !poisoned;
+        return !closed && !isPoisoned();
+    }
+
+    private boolean isPoisoned() {
+        return poisonCause != null;
     }
 
     @Override
@@ -342,10 +346,12 @@ public class LengthDelimitedJournal<T> implements WriteAheadJournal<T> {
 
 
     private void checkState() throws IOException {
-        if (poisoned) {
+        final Throwable cause = this.poisonCause;
+        if (cause != null) {
+            logger.debug("Cannot update Write Ahead Log because the log has already been poisoned", cause);
             throw new IOException("Cannot update journal file " + journalFile + " because this journal has already encountered a failure when attempting to write to the file. "
                 + "If the repository is able to checkpoint, then this problem will resolve itself. However, if the repository is unable to be checkpointed "
-                + "(for example, due to being out of storage space or having too many open files), then this issue may require manual intervention.");
+                + "(for example, due to being out of storage space or having too many open files), then this issue may require manual intervention.", cause);
         }
 
         if (closed) {
@@ -354,7 +360,9 @@ public class LengthDelimitedJournal<T> implements WriteAheadJournal<T> {
     }
 
     protected void poison(final Throwable t) {
-        this.poisoned = true;
+        this.poisonCause = t;
+
+        logger.error("Marking Write-Ahead journal file {} as poisoned due to {}", journalFile, t, t);
 
         try {
             if (fileOut != null) {
@@ -390,7 +398,7 @@ public class LengthDelimitedJournal<T> implements WriteAheadJournal<T> {
 
         try {
             if (fileOut != null) {
-                if (!poisoned) {
+                if (!isPoisoned()) {
                     fileOut.write(JOURNAL_COMPLETE);
                 }