Bug 401198

Summary: kmail fetches new mails twice
Product: [Frameworks and Libraries] Akonadi Reporter: m.eik michalke <bugs.kde.org>
Component: IMAP resourceAssignee: kdepim bugs <kdepim-bugs>
Status: REPORTED ---    
Severity: major    
Priority: NOR    
Version: 5.7.3   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description m.eik michalke 2018-11-19 10:06:47 UTC
since the upgrade from kubuntu 16.04 to 18.04 (both with packages from the kubuntu-backports PPA), kmail aquired a habbit of fetching new mails twice, which ultimately stops it from fetching any more mails from the IMAP server until the mess is manually cleaned up and akonadi restarted at least once.

STEPS TO REPRODUCE
1. start kmail (fetches mails on start and checks server every 5 minutes)

OBSERVED RESULT
right after launch, i can see for a brief moment that all new mails are fetched almost instantly, and my mail filters move most of them to designated folders, also on the IMAP server. after that, all folders are being checked for new arrivals, including the inbox, and by doing that almost all new mails are downloaded and filtered again. this leaves me up with a bunch of duplicate mails in various folders, and akonadi seems to be thrown off the tracks by its own doing, because somewhere during the IMAP folder updating it stalls with progress messaged like "foldername 103%". it's completely stuck now, but theres no warning or error. after a few hours you just begin to wonder why you didn't receive any mails all the time.

EXPECTED RESULT
mails should be fetched once only.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: kubuntu 18.04 + kubuntu backports PPA
KDE Plasma Version: 5.12.7
KDE Frameworks Version: 5.47.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION
i found a workaround per session:
1. remove the second(!) of all duplicate mails in the various IMAP folders; if you remove the first mail instead you might lose that mail later in the trash
2. in kmail, go to `settings` -> `configure kmail` -> `accounts` and restart the stuck receiving account
3. if the above doesn't help (it's sometimes stuck right again), run `akonadictl stop` and start it in kmail again

IMHO, this looks like a race condition, as if the IMAP inbox wasn't informed yet that the new mails have already been moved, before it is queried again. might be the duplicates are only virtual, and akonadi is confused by the mismatch of numbers.
Comment 1 m.eik michalke 2019-02-13 10:26:13 UTC
my workaround stopped working. i am losing mails on a daily basis!

there are two choices: either i leave the duplicate mails in the folders, in which case akonadi is stuck and doesn't fetch new mails. or i remove duplicate copies from the folders and restart the account, which now causes kmail to remove *all* new mails from the folder completely. if i'm lucky, i have copies in the trash.

this is totally unusable, please fix this.