[Dovecot] [PATCH] mailbox_get_metadata() for mailboxes with open transactions.
Timo Sirainen
tss at iki.fi
Tue Apr 16 17:14:55 EEST 2013
On 16.4.2013, at 17.04, Dafan Zhai <dafan.zhai at securepoint.de> wrote:
> I am writing a dovecot statistic plugin, which calls mailbox_get_metadata() to get the virtual size of the mailbox, if a mail is copied. I have noticed that mailbox_get_metadata() calls mailbox_sync(), and mailbox_sync() will fail for the mailboxes with open transactions. But if a mail is copied, there must be at least one transaction opened for the mailbox. So I can not get the virtual size.
If you hook into mailbox_copy() you'll be calling it for each mail separately that is copied within the same command. Also you're calling it even if the copy fails later (e.g. IMAP COPY gets aborted if some messages are missing). So you should delay calling it until after transaction commit (set your own flag to the transaction that messages were copied). Maybe even until the next sync is called.
> Commit [1] has fixed the same problem in mailbox_get_status(). I think the same should also be done in mailbox_get_metadata(). See the patch below.
Too much of a chance of breaking some code that relies on the current behavior.
More information about the dovecot
mailing list