Bug 393280

Summary: Repeated entries of 'Executing search "kontact-476707713-SearchSession"' in Akonadi log
Product: [Frameworks and Libraries] Akonadi Reporter: Kevin Funk <kfunk>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Status: CONFIRMED ---    
Severity: normal CC: dvratil
Priority: NOR    
Version: 5.7.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Kevin Funk 2018-04-19 07:26:59 UTC
This is happening each time I'm restarting the Akonadi server, during this time Kontact is using 100% CPU and is hardly usable. This goes on for around one minute and then these entries in the log just vanish, Kontact's CPU usage goes down and Kontact starts getting usable.

Log excerpt:
```
...
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0): Executing search "kontact-476707713-SearchSession"
akonadiserver(27868)/org.kde.pim.akonadiplugin_indexer: unknown(0): unknown term  "birthday" @ ?akonadiserver?|qt_message_output|QDebug::~QDebug|?akonadi_search_plugin.so?|?akonadi_search_plugin.so?|?akonadi_search_plugin.so?|?akonadiserver?|?akonadiserver?|?akonadiserver?|?akonadiserver?|QMetaObject::activate|QMetaObject::activate|?libQt5Network.so.5?|?libQt5Network.so.5?|?libQt5Network.so.5?|QCoreApplication::notifyInternal2|?libQt5Core.so.5?|g_main_context_dispatch|?libglib-2.0.so.0?|g_main_context_iteration
akonadiserver(27868)/org.kde.pim.akonadiplugin_indexer: unknown(0): unknown term  "birthday" @ ?akonadiserver?|qt_message_output|QDebug::~QDebug|?akonadi_search_plugin.so?|?akonadi_search_plugin.so?|?akonadi_search_plugin.so?|?akonadiserver?|?akonadiserver?|?akonadiserver?|?akonadiserver?|QMetaObject::activate|QMetaObject::activate|?libQt5Network.so.5?|?libQt5Network.so.5?|?libQt5Network.so.5?|QCoreApplication::notifyInternal2|?libQt5Core.so.5?|g_main_context_dispatch|?libglib-2.0.so.0?|g_main_context_iteration
akonadiserver(27868)/org.kde.pim.akonadiplugin_indexer: unknown(0): Got 10219 results
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0): Search done "kontact-476707713-SearchSession" (without remote search)
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     Result: 10219 matches
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0): SEARCH:
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     Query: "{\n    \"limit\": -1,\n    \"negated\": false,\n    \"rel\": 0,\n    \"subTerms\": [\n        {\n            \"cond\": 2,\n            \"key\": \"birthday\",\n            \"negated\": false,\n            \"value\": 2458228\n        },\n        {\n            \"cond\": 4,\n            \"key\": \"birthday\",\n            \"negated\": false,\n            \"value\": 2458235\n        }\n    ]\n}\n"
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     MimeTypes: ("text/directory")
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     Collections: QVector(0, 1081, 3267, 3055, 3148, 3260)
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     Remote: false
akonadiserver(27868)/org.kde.pim.akonadiserver: unknown(0):     Recursive true
...
```
Comment 1 Kevin Funk 2018-04-19 07:27:48 UTC
Akonadi version: 4:17.12.3-0ubuntu3
Comment 2 Kevin Funk 2018-09-04 08:04:24 UTC
Still experiencing this every time I restart the akonadiserver (which I have to do often b/c of mail sync stopping to work... -- different issue).

Could someone tell me how I can figure out the root cause of this particular issue?
Comment 3 Daniel Vrátil 2018-09-19 10:08:15 UTC
Whenever something changes in Akonadi we need to re-run persistent search queries to update the content of the "Search" folders in KMail, because currently there's no other way to figure out whether the new email matches the search filter or not (it's not run on every single change, but it is scheduled to run in about a second after the first change).

If the query affects many collections or has many results (like in your case, 10219), it can hinder the performance.

A workaround is to remove the persistent search folders from KMail (which sucks, I know...)

Proper fix, of course, is for me to figure out how to match a single email against the search query so we can evaluate it on per-email basis instead of having to re-run the entire search query every time.
Comment 4 Kevin Funk 2019-01-08 10:48:33 UTC
> A workaround is to remove the persistent search folders from KMail (which sucks, I know...)

How do I do that?

Note: Akonadi version now is: 4:18.04.3-0ubuntu2 (problem still persists)