stalwartlabs / mail-server

Secure & Modern All-in-One Mail Server (IMAP, JMAP, POP3, SMTP)
https://stalw.art
3.53k stars 135 forks source link

[bug]: Failed to auto-expunge messages #544

Closed yannikbloscheck closed 1 week ago

yannikbloscheck commented 1 week ago

What happened?

According to the error log the auto-expunging for messages doesn't work. I don't experience any real issues, but it shows up in my error log. So something has to be wrong. This issue appeared first after updating to version 0.8.1 from 0.8.0. The issue #543 could be related.

How can we reproduce the problem?

Waiting for the housekeeper to run at the configured time

Version

v0.8.1

What database are you using?

RocksDB

What blob storage are you using?

Filesystem

Where is your directory located?

Internal

What operating system are you using?

Linux

Relevant log output

2024-06-17T00:00:00.001995Z DEBUG jmap::services::housekeeper: Scheduling housekeeper event. due_in=86399 event=Account
2024-06-17T00:00:00.002050Z DEBUG jmap::services::housekeeper: Purging accounts.
2024-06-17T00:00:00.002773Z ERROR jmap::email::delete: Failed to generate reference cid. event="error" context="email_auto_expunge" account_id=1
2024-06-17T00:00:00.002803Z ERROR jmap::email::delete: Failed to auto-expunge messages. event="error" context="email_auto_expunge" account_id=1
2024-06-17T00:00:00.003533Z ERROR jmap::email::delete: Failed to generate reference cid. event="error" context="email_auto_expunge" account_id=2
2024-06-17T00:00:00.003548Z ERROR jmap::email::delete: Failed to auto-expunge messages. event="error" context="email_auto_expunge" account_id=2
2024-06-17T00:00:00.007372Z ERROR jmap::email::delete: Failed to generate reference cid. event="error" context="email_auto_expunge" account_id=3
2024-06-17T00:00:00.007385Z ERROR jmap::email::delete: Failed to auto-expunge messages. event="error" context="email_auto_expunge" account_id=3
...

Code of Conduct

mdecimus commented 1 week ago

I've checked the code where this error is generated and it occurs when it is not possible to calculate a date in the past. Do you have perhaps a very large value in the jmap.email.auto-expunge setting?

yannikbloscheck commented 1 week ago

Yes, it's a very large value. Especially if you calculate it in seconds internally. If it calculates backwards from the current date with it, the resulting date would be before the year 0. So that's probably the reason. I have reduced the value now. I will see what happens at the next housekeeping run at midnight and then report back. Maybe better handling of this error might be still be helpful anyway.

mdecimus commented 1 week ago

Are you using a large value because you want to disable autoexpunge? If that is the case you can just set the value to false instead of using a large value.

yannikbloscheck commented 1 week ago

Good to know as I wasn't aware of that. When updating I just wasn't sure which timespan I personally preferred and therefore just chose something big to put that decision off until later, but then I just forgot to change it to something sensible later.

yannikbloscheck commented 1 week ago

After now having set a smaller value as predicted by you the error doesn't seem to appear anymore. From my side this issue can now be closed, but I leave it up to you to close it in case you want to improve the handling of this error somehow (like maybe having a clearer error message) and still want to have this issue open until then.