Hello,
dovecot --version
2.3.20 (80a5ac675d)
When using hibernation (imap_hibernate_timeout = 10s), counters such
as deleted/expunged messages, appear to be reset after the user process
is recreated.
Steps to reproduce:
- Configure IMAP hibernation 
- Login with IMAP client 
- Delete+expunge a message 
- IDLE, and wait 10s for process to be hibernated 
- Unhibernate process ( - DONE), and log out
- Observe the logged line: - 2023-09-05T17:36:26+0200 imap(<redacted>)<776933><jA2nYJ4EPdcqAVtAAADwAAutur4AAAAB>: Info: Disconnected: Logged out in=9 out=88 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0 
The expected output is "deleted=1 expunged=1", not "deleted=0 expunged=0".
If you follow the steps above, but skip the IDLE/hibernate step, the output is as expected.
Interestingly, if the client is disconnected during hibernation (without
recreating the process), the output from imap-hibernate is still as
expected:
2023-09-05T17:45:15+0200 imap-hibernate(<redacted>)<770540><0qE0gJ4Emt8qAVtAAADwAAutur4AAAAB>: Info: Disconnected: Connection closed in=97 out=1020 deleted=1 expunged=1 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
This leads me to believe the counters are lost during process recreation, not during hibernation.
This is an issue as customers will often come to us asking why messages have disappeared in their inbox, or asking for help to identify which client is expunging messages.
Right now, this information is lost if hibernation is used and the client is hibernated after expunging.
Best regards, Eirik Rye