Bug 421114

Summary: Excessive CPU usage and logging (ItemRetrievalJob) in KMail / Akonadi when mail draft or template does not include any text / has empty body
Product: [Frameworks and Libraries] Akonadi Reporter: null <null>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: GIT (master)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description null 2020-05-06 17:32:31 UTC
When composing a message and saving it as a draft without having written any text yet, akonadiserver will become very busy, resulting in a sluggish overall system. Note that this also affects saving as a template, where having an empty text area could be considered a common use case.

Symptoms include the log filling up with
> org.kde.pim.akonadiserver: ItemRetrievalJob for request 646 finished
(with the counter incrementing by one each time) even when KMail is idle/unfocussed.

There are two cases for the logging frequency:
- several messages a second if the mail is selected, going along with very high CPU usage (kmail, mysqld and akonadiserver in particular)
- a message every 5 seconds if a different (non-broken) mail is selected
The issue persists even after restarting KMail and Akonadi.

Steps to reproduce:
- start KMail with a clean KMail/Akonadi config
- no need to create any account besides "Local Folders"
- create new mail, leave all fields empty, save as draft
- select mail, notice high CPU usage and excessive logging
- edit mail by adding text in the message editor, save as draft again
- notice CPU becoming idle again, no more logging

Affected versions:
- can be reproduced with KF5 and KDE PIM from git master as of today (5.14.40) and Qt 5.14.1
- KMail 5.9.2 is affected too
- KMail 5.5.2 is _not_ affected

Possibly related: Bug 398407