When does Dovecot lazy expunge actually free quota and shrink the index under concurrent IMAP load?
0 reputation · 18 Jul 2020, 16:05 UTC
0 reputation · 18 Jul 2020, 16:05 UTC
I'm evaluating whether to enable lazy_expunge = yes on a Dovecot 2.3.x server that hosts busy mailboxes in mdbox format. The documented behavior is clear in principle: expunged messages stay in storage and in the index until a later expunge pass, which avoids immediate disk I/O on the hot path.
What I cannot pin down is the practical timing. If deleted messages remain indexed, quota should not reflect the freed space right away, and the index should keep growing until doveadm expunge runs. But the documentation does not state whether mailbox close, a periodic plugin trigger, or only an explicit doveadm expunge -A actually processes the deferred removals, and how that interacts with many simultaneous IMAP sessions on the same mailbox.
I plan to verify with doveadm status -v counters and imaptest load, but before designing the test I want to understand the intended semantics.
Specifically: which events trigger processing of lazy-expunged messages in 2.3.x, and is it purely manual? Does concurrent access from multiple sessions delay or duplicate that processing? And is there a supported way to bound how much deferred-deletion storage accumulates before quota appears to recover?
With lazy_expunge = yes Dovecot does not free quota or shrink the index immediately when a message is expunged via IMAP. The message is moved to the lazy_expunge namespace (usually a hidden .EXPUNGED mailbox) and its storage and index entries remain until an explicit expunge operation runs against that namespace.
doveadm expunge (or equivalent) on the lazy_expunge mailbox; there is no automatic trigger on mailbox close or via a plugin timer in 2.3.x.doveadm expunge with age or size criteria to bound accumulation.lazy_expunge = yes and note the configured lazy_expunge namespace (default .EXPUNGED).doveadm status -v or doveadm quota get -u user to record baseline quota and index size.doveadm expunge -u user mailbox).doveadm expunge -u user mailbox .EXPUNGED savedbefore 1d (adjust namespace and age as needed).If your quota is enforced by the filesystem rather than Dovecot's quota plugin, lazy-expunged bytes will always count toward the limit until the files are physically deleted. Confirm whether you rely on Dovecot's quota plugin or external filesystem quota to interpret the numbers correctly.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.