Ldap – Zimbra: stuck .msg files and phantom messages in mailboxes

cleanupldapzimbra

Users in my org use Outlook 2010 e-mail client with pop3 access to ZCS/OSE. These clients are using default "delete messages from server after 14 days" setting
All message boxes are set up as follows:

  1. Store not more 450 Mb per mailbox
  2. TTL for regular message is 60 days and for trash/spam is 30 days.

Purging activity works as supposed to be. But…
Manual reindexing a mailbox from admin GUI shows that there 5000+ (more than five thousands) messages to index, but total number of items (mail+calendar+…) as about 300 (three hundreds or less a bit).

More, the examination of /opt/zimbra/storage subdirs shos that some .msg files stored there are from 2009 year!

And some mailboxes looks full, even if there aren't any messages in any mailbox folders. Just because account's subdirectory is filled with old, deleted for long time ago messages.

Can anybody explain, if theres any possibility to really purge obsoleted message files? FINDing them with mtime parameter and deleting does not looks very good idea. I did that, unfortunately. But zimbra stores something in its LDAP server and forcibly "killed" messages are still visible, even if they could not be opened because of "BLOB missing" error.

Is there any way to sanitize ZCS' LDAP directory?

Best Answer

Zimbra doesn't store message metadata on LDAP. Instead zimbra use MySQL to store it. Snippet from Zimbra wiki: Account mailbox database structure

Zimbra uses mysql databases to store mail header information (To, From, Subject, Date, Read/Unread Status, Flags, Tags), contacts, calendar items, and tasks. Zimbra automatically assigns a zimbra account to a mailbox group when the account is created. The mailbox group corresponds to a database located in /opt/zimbra/db/data such as mboxgroup1, mboxgroup2, ...etc. There are a maximum of 100 mailbox groups per mailbox server.

The first task here is fix inconsistency between Zimbra blob and MySQL metadata. You can use zimbra helper called zmblobchk. This command checks the consistency of the Zimbra blob store (/opt/zimbra/store). This command checks and records notes of files without matching database metadata. It also checks to make sure that size information is correct for the files.

The second task is find out why the message still present if the outlook has tell zimbra to delete it. You can try to check zimbra logs, perhaps some Zimbra worker has an error so the automatic deletion process failed.


Convenient mini-script to check and reindex, credit to OP

mbox=USERNAME;aa=`zmprov gmi $mbox|grep mailbox|sed -e "s/mailboxId\:\ //"`; zmblobchk -m $aa --export-dir /tmp/zmblb/ --missing-blob-delete-item start; zmprov rim $mbox start; zmprov rim $mbox status
Related Topic