foxcpp / maddy

✉️ Composable all-in-one mail server.
https://maddy.email
GNU General Public License v3.0
5k stars 240 forks source link

Corrupted mail DB (stuck in recovery mode) #501

Closed angelnu closed 2 years ago

angelnu commented 2 years ago

Describe the bug

I get the following logs from Maddy:

imapsql: MoveMessages (decrease counters) [true 9357 Trash]: driver: bad connection {"mbox":"INBOX","mboxId":28,"username":"angel@example.com","uid":1}
imapsql: MoveMessages (tx start) [true 9357 Trash]: pq: the database system is in recovery mode {"mbox":"INBOX","mboxId":28,"username":"angel@example.com","uid":1}
imapsql: ListMessages (tx start) [true 9358:* [FLAGS UID]]: pq: the database system is in recovery mode {"mbox":"INBOX","mboxId":28,"username":"angel@example.com","uid":1}
imapsql: ListMessages (tx start) [true 1:* [FLAGS UID]]: pq: the database system is in recovery mode {"mbox":"INBOX","mboxId":28,"username":"angel@example.com","uid":1} 

...

imapsql: Expunge (deleteZeroRef) []: driver: bad connection {"mbox":"bla.Trash","mboxId":3,"username":"angel@angelnu.com","uid":1}
imapsql: Expunge (deleteZeroRef) []: driver: bad connection {"mbox":"bla.Trash","mboxId":3,"username":"angel@angelnu.com","uid":1} 

What do you think is wrong?

I think the Junk imap folder is corrupted. I tried renaming it to bla.Trash and creating a new one (called it Trash). But the old one still seems to be used.

Ideally there would be instructions to remove corrupted folders without having to restore a DB backup as this problem only seems to affect one single user so I do not want to loose email from the other users if it can be avoided.

Steps to reproduce

Not sure - it came up after I restarted my servers to do so some network upgrades. I use a cluster postgres but there I do not see any errors.

Log files

Posted above.

Configuration file

Located in /etc/maddy/maddy.conf by default, don't forget to remove DB passwords and other security-related stuff. I do not expect is relevant

Environment information

foxcpp commented 2 years ago

PostgreSQL logs help figuring out why the DB is in recovery mode.

Ideally there would be instructions to remove corrupted folders without having to restore a DB backup as this problem only seems to affect one single user so I do not want to loose email from the other users if it can be avoided.

These instructions would depend on what kind of "corruption" it is.

angelnu commented 2 years ago

The DB seems to have recovered in the meanwhile: I can now empty the trash folder and I do not longer see any error log in Maddy.

So closing - thanks.