Deleting messages from filesystem with sdbox mail format
Dear list, I recently had to delete some messages from an sdbox mailbox, for which I used the canonical "doveadm expunge" command without issues.
However I got curious and, on a test mailbox, I deleted an unimportant message directly from the filesystem (rm u.650). After removing the file, the webmail continued to show it in the mail list - but no text was retrieved when I selected it. I supposed this was due to dovecot.index.cache and, indeed, deleting the cache got rid of the message in the webmail list.
While I understand that it is not recommended (deleting and regenerating the index cache is an expensive operation), I wonder if removing a file from the filesystem, and regenerating the index cache file, is a safe operation when using an sdbox mailstore. Specifically, I would like to know if, after a manual filesystem deletion, the main index file (dovecot.index) is automatically updated by dovecot (reflecting the deletion) or if lingering references are kept in it.
Thanks.
-- Danti Gionatan Supporto Tecnico Assyoma S.r.l. - www.assyoma.it [1] email: g.danti@assyoma.it - info@assyoma.it GPG public key ID: FF5F32A8
On 11/05/2020 16:45 Gionatan Danti g.danti@assyoma.it wrote:
Dear list, I recently had to delete some messages from an sdbox mailbox, for which I used the canonical "doveadm expunge" command without issues.
However I got curious and, on a test mailbox, I deleted an unimportant message directly from the filesystem (rm u.650). After removing the file, the webmail continued to show it in the mail list - but no text was retrieved when I selected it. I supposed this was due to dovecot.index.cache and, indeed, deleting the cache got rid of the message in the webmail list.
While I understand that it is not recommended (deleting and regenerating the index cache is an expensive operation), I wonder if removing a file from the filesystem, and regenerating the index cache file, is a safe operation when using an sdbox mailstore. Specifically, I would like to know if, after a manual filesystem deletion, the main index file (dovecot.index) is automatically updated by dovecot (reflecting the deletion) or if lingering references are kept in it.
Thanks.
-- Danti Gionatan
If you manually change the mailbox contents like that, you need to run doveadm force-resync to fix the situation.
Aki
Il 2020-05-11 15:54 Aki Tuomi ha scritto:
If you manually change the mailbox contents like that, you need to run doveadm force-resync to fix the situation.
Aki
Ok, so it means that dovecot will *not* automatically fix the index file and I need to reconstruct the index file, right?
Just for completeness: will not fixing the index file (after a manual deletion) cause unexpected issues, or "only" lingering reference to a delete email?
Thanks.
-- Danti Gionatan Supporto Tecnico Assyoma S.r.l. - www.assyoma.it [1] email: g.danti@assyoma.it - info@assyoma.it GPG public key ID: FF5F32A8
On 11/05/2020 17:37 Gionatan Danti g.danti@assyoma.it wrote:
Il 2020-05-11 15:54 Aki Tuomi ha scritto:
If you manually change the mailbox contents like that, you need to run doveadm force-resync to fix the situation.
Aki
Ok, so it means that dovecot will *not* automatically fix the index file and I need to reconstruct the index file, right?
Just for completeness: will not fixing the index file (after a manual deletion) cause unexpected issues, or "only" lingering reference to a delete email?
Thanks.
-- Danti Gionatan
The index will be rebuilt once you try to access the mail.
Aki
Il 2020-05-11 17:41 Aki Tuomi ha scritto:
The index will be rebuilt once you try to access the mail.
Hi Aki, I probably misunderstood yor previous reply. So, the index will be fixed when either:
- running doveadm force-sync
- accessing the mailbox (ie: via IMAP).
This means that removing an email from the filesystem (ie: a u.* file) and the index cache file (dovecot.index.cache) should be safe, as the main index file (dovecot.index) will be fixed when accessing the mailbox.
Am I missing something? Thanks.
-- Danti Gionatan Supporto Tecnico Assyoma S.r.l. - www.assyoma.it [1] email: g.danti@assyoma.it - info@assyoma.it GPG public key ID: FF5F32A8
On 11/05/2020 19:48 Gionatan Danti g.danti@assyoma.it wrote:
Il 2020-05-11 17:41 Aki Tuomi ha scritto:
The index will be rebuilt once you try to access the mail.
Hi Aki, I probably misunderstood yor previous reply. So, the index will be fixed when either:
- running doveadm force-sync
- accessing the mailbox (ie: via IMAP).
This means that removing an email from the filesystem (ie: a u.* file) and the index cache file (dovecot.index.cache) should be safe, as the main index file (dovecot.index) will be fixed when accessing the mailbox.
Am I missing something? Thanks.
-- Danti Gionatan Supporto Tecnico
Except now you lost the cache. Which is not really necessary. Why not use 'doveadm expunge -u victim mailbox box uid number' instead? The uid number is same as the number in file name.
Aki
Il 2020-05-11 18:51 Aki Tuomi ha scritto:
Except now you lost the cache. Which is not really necessary. Why not use 'doveadm expunge -u victim mailbox box uid number' instead? The uid number is same as the number in file name.
Sure - I used it and worked like a charm!
I was just curious to understand if/how an apparently "harmless" operation (deleting an unwanted email file) can result in serious index problems.
Thank you so much.
-- Danti Gionatan Supporto Tecnico Assyoma S.r.l. - www.assyoma.it [1] email: g.danti@assyoma.it - info@assyoma.it GPG public key ID: FF5F32A8
participants (2)
-
Aki Tuomi
-
Gionatan Danti