Return-Path: X-Original-To: apmail-activemq-issues-archive@minotaur.apache.org Delivered-To: apmail-activemq-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E002F186F3 for ; Thu, 10 Sep 2015 17:30:07 +0000 (UTC) Received: (qmail 59075 invoked by uid 500); 10 Sep 2015 17:29:45 -0000 Delivered-To: apmail-activemq-issues-archive@activemq.apache.org Received: (qmail 59035 invoked by uid 500); 10 Sep 2015 17:29:45 -0000 Mailing-List: contact issues-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 issues@activemq.apache.org Received: (qmail 59016 invoked by uid 99); 10 Sep 2015 17:29:45 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Sep 2015 17:29:45 +0000 Date: Thu, 10 Sep 2015 17:29:45 +0000 (UTC) From: "Stephanie M (JIRA)" To: issues@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AMQ-3978) Allow KahaDB to "compact" journal files to remove messages that are no longer needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMQ-3978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14739194#comment-14739194 ] Stephanie M commented on AMQ-3978: ---------------------------------- My solution has been to purge the DLQ by cron nightly using JMX calls. > Allow KahaDB to "compact" journal files to remove messages that are no longer needed > ------------------------------------------------------------------------------------ > > Key: AMQ-3978 > URL: https://issues.apache.org/jira/browse/AMQ-3978 > Project: ActiveMQ > Issue Type: Improvement > Components: KahaDB, Message Store > Affects Versions: 5.6.0 > Reporter: Tim Bain > Priority: Minor > > KahaDB uses a write-only journaling approach that ensures that a journal file will be deleted only when no content within it is still in use. If a single byte of the file is still needed, the entire file must be kept, even if the rest of the file is not needed. > This works fine when all messages are immediately removed from destinations within an ActiveMQ broker, but it fails ungracefully when messages that are consumed infrequently (or not at all, relying on TTL to delete the messages) are interspersed with large volumes of messages that are consumed quickly. In this scenario, if a single infrequently-consumed message ends up in a journal file with a large number of quickly-consumed messages, the entire file will be kept even though nearly all of the content of the file is no longer needed. When this happens for enough journal files, the KahaDB's disk/file limits are reached, even though the amount of actual "live" data within the KahaDB is far below the configured limits. > To fix this, the periodic cleanup task that already looks for files that are unused should be changed so that if it determines that it cannot delete the file because it contains at least one live message but it contains less than a configurable percentage of live messages, the task will rewrite the journal file in question so it contains only those live messages into file, updating any in-memory indices that might show the offsets of messages within the file (if there are any such things). If any in-memory data structures will need to be updated, we need to appropriately synchronize to ensure that no one can use the portions of the data structure related to the file currently being compacted; access to similar information for all other data files can continue unrestricted. > Note that this will result in us still having potentially many individual files, with each one having a much smaller file size than our target size. If that is problematic, it would be possible to combine multiple partial files together during the compaction process (while respecting the max file size) instead of writing live messages back into their current file. -- This message was sent by Atlassian JIRA (v6.3.4#6332)