activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-351 throw an exception if we get an IOException
Date Tue, 19 Jan 2016 18:03:21 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 54222d866 -> 1dc7a8946


ARTEMIS-351 throw an exception if we get an IOException


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7b164e45
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7b164e45
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7b164e45

Branch: refs/heads/master
Commit: 7b164e45c37e4386b1d53a146045b51e38b34aec
Parents: 54222d8
Author: Tom Jenkinson <tom.jenkinson@redhat.com>
Authored: Fri Jan 15 20:55:06 2016 +0000
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Jan 19 13:02:57 2016 -0500

----------------------------------------------------------------------
 .../journal/impl/JournalFilesRepository.java    | 33 ++++++++++++++------
 1 file changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7b164e45/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
index 066638b..fe9d905 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.journal.ActiveMQJournalBundle;
@@ -418,8 +419,10 @@ public class JournalFilesRepository {
     * <p>This method will instantly return the opened file, and schedule opening and
reclaiming.</p>
     * <p>In case there are no cached opened files, this method will block until the
file was opened,
     * what would happen only if the system is under heavy load by another system (like a
backup system, or a DB sharing the same box as ActiveMQ).</p>
+    *
+    * @throws ActiveMQIOErrorException In case the file could not be opened
     */
-   public JournalFile openFile() throws InterruptedException {
+   public JournalFile openFile() throws InterruptedException, ActiveMQIOErrorException {
       if (JournalFilesRepository.trace) {
          JournalFilesRepository.trace("enqueueOpenFile with openedFiles.size=" + openedFiles.size());
       }
@@ -431,13 +434,13 @@ public class JournalFilesRepository {
          openFilesExecutor.execute(pushOpenRunnable);
       }
 
-      JournalFile nextFile = null;
-
-      while (nextFile == null) {
-         nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
-         if (nextFile == null) {
-            fileFactory.onIOError(ActiveMQJournalBundle.BUNDLE.fileNotOpened(), "unable to
open ",  null);
-         }
+      JournalFile nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
+      if (nextFile == null) {
+         fileFactory.onIOError(ActiveMQJournalBundle.BUNDLE.fileNotOpened(), "unable to open
", null);
+         // We need to reconnect the current file with the timed buffer as we were not able
to roll the file forward
+         // If you don't do this you will get a NPE in TimedBuffer::checkSize where it uses
the bufferobserver
+         fileFactory.activateBuffer(journal.getCurrentFile().getFile());
+         throw ActiveMQJournalBundle.BUNDLE.fileNotOpened();
       }
 
       if (JournalFilesRepository.trace) {
@@ -465,7 +468,19 @@ public class JournalFilesRepository {
    public void closeFile(final JournalFile file) throws Exception {
       fileFactory.deactivateBuffer();
       file.getFile().close();
-      dataFiles.add(file);
+      if (!dataFiles.contains(file)) {
+         // This is not a retry from openFile
+         // If you don't check this then retries keep adding the same file into
+         // dataFiles list and the compactor then re-adds multiple copies of the
+         // same file into freeFiles.
+         // The consequence of that is that you can end up with the same file
+         // twice in a row in the list of openedFiles
+         // The consequence of that is that JournalImpl::switchFileIfNecessary
+         // will throw throw new IllegalStateException("Invalid logic on buffer allocation")
+         // because the file will be checked effectively twice and the buffer will
+         // not fit in it
+         dataFiles.add(file);
+      }
    }
 
    /**


Mime
View raw message