activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [activemq-artemis] 02/03: ARTEMIS-2274 Fix on Journal buffer overflow with almost large messages
Date Wed, 13 Mar 2019 19:04:04 GMT
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 828a4856da83ae11ecdee2f87face0f1f624b049
Author: Clebert Suconic <clebertsuconic@apache.org>
AuthorDate: Wed Mar 13 14:55:22 2019 -0400

    ARTEMIS-2274 Fix on Journal buffer overflow with almost large messages
---
 .../org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java     | 2 +-
 .../core/persistence/impl/journal/LargeServerMessageImpl.java       | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java
index d49f930..942f88c 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java
@@ -244,7 +244,7 @@ public final class TimedBuffer extends CriticalComponentImpl {
             }
 
             if (sizeChecked > bufferSize) {
-               throw new IllegalStateException("Can't write records bigger than the bufferSize("
+ bufferSize + ") on the journal");
+               throw new IllegalStateException("Can't write records (size=" + sizeChecked
+ ") bigger than the bufferSize(" + bufferSize + ") on the journal");
             }
 
             if (bufferLimit == 0 || buffer.writerIndex() + sizeChecked > bufferLimit)
{
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index 42a76be..153c583 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -42,13 +42,17 @@ import io.netty.buffer.Unpooled;
 
 public final class LargeServerMessageImpl extends CoreMessage implements LargeServerMessage
{
 
+   // When a message is stored on the journal, it will contain some header and trail on the
journal
+   // we need to take that into consideration if that would fit the Journal TimedBuffer.
+   private static final int ESTIMATE_RECORD_TRAIL = 512;
+
    /** This will check if a regular message needs to be converted as large message */
    public static Message checkLargeMessage(Message message, StorageManager storageManager)
throws Exception {
       if (message.isLargeMessage()) {
          return message; // nothing to be done on this case
       }
 
-      if (message.getEncodeSize() > storageManager.getMaxRecordSize()) {
+      if (message.getEncodeSize() + ESTIMATE_RECORD_TRAIL > storageManager.getMaxRecordSize())
{
          return asLargeMessage(message, storageManager);
       } else {
          return message;


Mime
View raw message