From commits-return-55480-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Wed Mar 13 19:04:05 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 94DF8180763 for ; Wed, 13 Mar 2019 20:04:04 +0100 (CET) Received: (qmail 59769 invoked by uid 500); 13 Mar 2019 19:04:03 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 59746 invoked by uid 99); 13 Mar 2019 19:04:03 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Mar 2019 19:04:03 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 36C2785257; Wed, 13 Mar 2019 19:04:03 +0000 (UTC) Date: Wed, 13 Mar 2019 19:04:04 +0000 To: "commits@activemq.apache.org" Subject: [activemq-artemis] 02/03: ARTEMIS-2274 Fix on Journal buffer overflow with almost large messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: clebertsuconic@apache.org In-Reply-To: <155250384284.32400.14626396740446768385@gitbox.apache.org> References: <155250384284.32400.14626396740446768385@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: activemq-artemis X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 828a4856da83ae11ecdee2f87face0f1f624b049 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190313190403.36C2785257@gitbox.apache.org> 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 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;