KahaDB is a file based database which is by default used by Apache ActiveMQ. It stores the messages in log files with a file name format data-id.log.  A very common problem in KahaDB is that the ActiveMQ broker is unable to delete the old log files which starts accumulating and eventually consuming GB’s of data on hard disk drive.

When ActiveMQ broker is unable to delete old log files, we definitely want to get rid of those log files. If we simply delete the .log file then an error will be thrown next time ActiveMQ is restarted(web-app deployed). Error will look something like this:

 

Detected missing/corrupt journal files.

 

KahaDB logs are not safe to delete because the log files are referred by the db.data file which contains reference to those files. So, when an attempt is made to access the deleted log file after reading db.data, it throws the above error. A better approach to deal with this issue is to delete the db.data file alongwith the log files because kahaDB will re-generate the index(db.data) and reference to old files will no longer exist.

db.data” file can be accessed from the following path:

“(Path of data directory that is configured)/localhost/KahaDB/db.data”

A software level solution in Grails is to configure the following:


amq.'persistenceAdapter' {

amq.'kahaDB'(directory: "KahaDB Dir on our server",

checksumJournalFiles: true,

checkForCorruptJournalFiles: true,

ignoreMissingJournalfiles: true)

}

Setting “ignoreMissingJournalfiles” flag to true solves this problem as it will ignore missing journal files and continue with the execution.

 

That was all! 🙂