[Dovecot] [PATCH] mailbox_get_metadata() for mailboxes with open transactions.
Hi everyone,
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.
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.
Dovecot version: 2.2.0
OS: OS: Linux 3.4.39-dist i686
maildir:~/Maildir:LAYOUT=fs:INBOX=~/Maildir/INBOX
Dafan
[1] http://hg.dovecot.org/dovecot-2.2/rev/12136db6e31f
# HG changeset patch
# User Dafan Zhai
On 16.4.2013, at 17.04, Dafan Zhai dafan.zhai@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.
participants (2)
-
Dafan Zhai
-
Timo Sirainen