You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/10/18 00:50:16 UTC

activemq-artemis git commit: ARTEMIS-2131 Error compacting journal

Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 48e0fc8f4 -> 878b31018


ARTEMIS-2131 Error compacting journal

Compaction cannot free a sliced view of a ByteBuffer on Java >=9:
the fix is using the original ByteBuffer instead of the slice
to perform a file write and allow it to be correctly released by
the Cleaner.

(cherry picked from commit cae253d1367c4d3423670af9c769f7885579b631)


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

Branch: refs/heads/2.6.x
Commit: 878b310184815a13c26dbe212e81f4cb13eeba0c
Parents: 48e0fc8
Author: Francesco Nigro <ni...@gmail.com>
Authored: Wed Oct 17 15:10:04 2018 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Oct 17 20:50:10 2018 -0400

----------------------------------------------------------------------
 .../core/journal/impl/AbstractJournalUpdateTask.java    | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/878b3101/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
index 7740bef..10f5008 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
@@ -56,6 +56,8 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback
 
    private ActiveMQBuffer writingChannel;
 
+   private ByteBuffer bufferWrite;
+
    private final ConcurrentLongHashSet recordsSnapshot;
 
    protected final List<JournalFile> newDataFiles = new ArrayList<>();
@@ -214,11 +216,17 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback
          // To Fix the size of the file
          writingChannel.writerIndex(writingChannel.capacity());
 
-         sequentialFile.writeDirect(writingChannel.toByteBuffer(), true);
+         bufferWrite.clear()
+            .position(writingChannel.readerIndex())
+            .limit(writingChannel.readableBytes());
+
+         sequentialFile.writeDirect(bufferWrite, true);
          sequentialFile.close();
          newDataFiles.add(currentFile);
       }
 
+      bufferWrite = null;
+
       writingChannel = null;
    }
 
@@ -237,7 +245,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback
    protected void openFile() throws Exception {
       flush();
 
-      ByteBuffer bufferWrite = fileFactory.newBuffer(journal.getFileSize());
+      bufferWrite = fileFactory.newBuffer(journal.getFileSize());
 
       writingChannel = ActiveMQBuffers.wrappedBuffer(bufferWrite);