ActiveMQ recover corrupt KahaDB

 Getting a message about corrupt files or missing indexes from kahadb when ActiveMQ starts?

We've seen that sometimes copying the kahadb entry to another broker and trying again (there are differences in the Java and sometimes ActiveMQ versions) works.

Another way that will work is to make a backup of the kahadb directory and then in the original location, delete db.redo and files. This will cause ActiveMQ to rescan the indexes and rebuild the information. It will take a little time; I'd estimate 10-20s for a GB, but that will depend heavily on your infrastructure. For 50GB, it took roughly 10 min for us.

-rwxr-xr-x. 1 activemq activemq        8 Jul 22 21:31 lock
-rw-rw-r--. 1 activemq activemq  1725984 Jul 22 21:36 db-35.log
-rw-rw-r--. 1 activemq activemq  6156701 Jul 22 21:42 db-36.log
-rw-rw-r--. 1 activemq activemq 14464113 Jul 22 21:48 db-37.log
-rw-rw-r--. 1 activemq activemq  3695664 Jul 22 21:53 db-38.log
-rw-rw-r--. 1 activemq activemq  9236794 Jul 22 21:59 db-39.log
-rw-rw-r--. 1 activemq activemq  3233605 Jul 23 19:53 db-34.log
-rwxr-xr-x. 1 activemq activemq  3299608 Jul 24 13:09 db.redo
-rwxr-xr-x. 1 activemq activemq 45191168 Jul 24 13:09

Delete the bottom two: db.redo and then restart activemq and watch the logs for progress in recovering the messages.


Popular Posts