Bug 379153

Summary: The server crashes when running akonadictl fsck
Product: [Frameworks and Libraries] Akonadi Reporter: Christophe Marin <christophe>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: dvratil
Priority: NOR    
Version: GIT (master)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.6.1
Attachments: full backtrace

Description Christophe Marin 2017-04-24 09:47:07 UTC
Using master from this morning (but it happened before) and still using the psql backend

While trying to figure if akonadictl fsck was still hanging, I ran it in gdb.

the server crashed and restarted (and fsck is stuck in gdb :))

11:41:43 - akonadiserver(32143) -  : ASSERT failure in Akonadi::Search::Query::exec: "A query is being initialized without a type", file /kde/src/5/akonadi-search/core/query.cpp, line 227

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f144dae16ea in __GI_abort () at abort.c:78
#2  0x000000000061face in akMessageHandler (type=QtFatalMsg, context=..., msg=...) at /kde/src/5/akonadiserver/src/shared/akdebug.cpp:167
#3  0x00007f144e489e48 in qt_message(QtMsgType, QMessageLogContext const&, char const*, __va_list_tag*) () from /usr/lib64/libQt5Core.so.5
#4  0x00007f144e48b6e6 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib64/libQt5Core.so.5
#5  0x00007f144e487141 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f143c16a06f in Akonadi::Search::Query::exec (this=0x7f143db86aa0) at /kde/src/5/akonadi-search/core/query.cpp:227
#7  0x00007f143c181463 in ?? () from /usr/lib64/qt5/plugins/akonadi/akonadi_search_plugin.so
#8  0x00000000005f386f in Akonadi::Server::SearchRequest::searchPlugins (this=0x7f143db87388) at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:111
#9  0x00000000005f39fd in Akonadi::Server::SearchRequest::exec (this=0x7f143db87388) at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:122
#10 0x000000000058a4d4 in Akonadi::Server::StorageJanitor::findOprhanSearchIndexEntries (this=0x210fb70) at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:750
#11 0x000000000058032b in Akonadi::Server::StorageJanitor::check (this=0x210fb70) at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:135
#12 0x00000000005a0686 in Akonadi::Server::StorageJanitor::qt_static_metacall (_o=0x210fb70, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f143db87770) at /kde/build/5/akonadiserver/src/server/libakonadiserver_automoc.dir/moc_storagejanitor_OBLQEFGAT4FLQK.cpp:96
#13 0x00000000005a0955 in Akonadi::Server::StorageJanitor::qt_metacall (this=0x210fb70, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f143db87770) at /kde/build/5/akonadiserver/src/server/libakonadiserver_automoc.dir/moc_storagejanitor_OBLQEFGAT4FLQK.cpp:146
#14 0x00007f144ed107e0 in QDBusConnectionPrivate::deliverCall(QObject*, int, QDBusMessage const&, QVector<int> const&, int) () from /usr/lib64/libQt5DBus.so.5
#15 0x00007f144ed151db in QDBusConnectionPrivate::activateCall(QObject*, int, QDBusMessage const&) () from /usr/lib64/libQt5DBus.so.5
#16 0x00007f144ed1578c in QDBusConnectionPrivate::activateObject(QDBusConnectionPrivate::ObjectTreeNode&, QDBusMessage const&, int) () from /usr/lib64/libQt5DBus.so.5
#17 0x00007f144ed180be in QDBusActivateObjectEvent::placeMetaCall(QObject*) () from /usr/lib64/libQt5DBus.so.5
#18 0x00007f144e68dc91 in QObject::event(QEvent*) () from /usr/lib64/libQt5Core.so.5
#19 0x00007f144e662f93 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib64/libQt5Core.so.5
#20 0x00007f144e66560d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib64/libQt5Core.so.5
#21 0x00007f144e6b44f3 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /usr/lib64/libQt5Core.so.5
#22 0x00007f144a9ce887 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#23 0x00007f144a9ceaf0 in ?? () from /usr/lib64/libglib-2.0.so.0
#24 0x00007f144a9ceb9c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#25 0x00007f144e6b48ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#26 0x00007f144e66152a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#27 0x00007f144e49fa5b in QThread::exec() () from /usr/lib64/libQt5Core.so.5
#28 0x00007f144e4a4469 in QThreadPrivate::start(void*) () from /usr/lib64/libQt5Core.so.5
#29 0x00007f144cbb0537 in start_thread (arg=0x7f143db88700) at pthread_create.c:456
#30 0x00007f144db9804f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
Comment 1 Christophe Marin 2017-04-24 09:47:59 UTC
mh.. I'll revisit the bug later, something looks wrong in the bt
Comment 2 Christophe Marin 2017-04-24 10:04:49 UTC
This one is nicer 

#5  0x00007fc4a409b141 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib64/libQt5Core.so.5
#6  0x00007fc49801506f in Akonadi::Search::Query::exec (this=0x7fc4937fcb90) at /kde/src/5/akonadi-search/core/query.cpp:227
#7  0x00007fc4a5189f45 in SearchPlugin::search (this=0x7fc47c003320, akonadiQuery=..., collections=..., mimeTypes=...)
    at /kde/src/5/akonadi-search/akonadiplugin/searchplugin.cpp:357
#8  0x00007fc4a518a7c3 in non-virtual thunk to SearchPlugin::search(QString const&, QVector<long long> const&, QStringList const&)
    () from /kde/inst/5/lib64/plugins/akonadi/akonadi_search_plugin.so
#9  0x00000000005f386f in Akonadi::Server::SearchRequest::searchPlugins (this=0x7fc4937fd388)
    at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:111
#10 0x00000000005f39fd in Akonadi::Server::SearchRequest::exec (this=0x7fc4937fd388)
    at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:122
#11 0x000000000058a4d4 in Akonadi::Server::StorageJanitor::findOprhanSearchIndexEntries (this=0x2612ed0)
    at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:750
#12 0x000000000058032b in Akonadi::Server::StorageJanitor::check (this=0x2612ed0)
    at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:135
#13 0x00000000005a0686 in Akonadi::Server::StorageJanitor::qt_static_metacall (_o=0x2612ed0, _c=QMetaObject::InvokeMetaMethod, 
    _id=2, _a=0x7fc4937fd770)
Comment 3 Daniel Vrátil 2017-04-24 10:39:05 UTC
Hmnm, that looks like you have a Collection that does not have any mimetypes...

When you run "akonadictl fsck", you should see "Checking Collection X search index..." just before the crash. Could you check in Akonadi Console whether the given Collection really does not have any mimetypes?
Comment 4 Christophe Marin 2017-04-24 11:03:33 UTC
Well, the last line is  Checking Collection 1 search index...

and collection 1 is the search one.

in collectionmimetyperelation, there's no collection_id=1
Comment 5 Daniel Vrátil 2017-05-02 09:55:21 UTC
Git commit 6934738a92c8b52a54522474692b98abb9d23736 by Daniel Vrátil.
Committed on 02/05/2017 at 09:55.
Pushed by dvratil into branch 'master'.

StorageJanitor: skip search index check of Collections without mimetype

Without mimetype we don't know which search store to look into,
but it also means that the Indexing Agent should not be able to
index it, so there should be no invalid indexed items.

M  +12   -0    src/server/storagejanitor.cpp

https://commits.kde.org/akonadi/6934738a92c8b52a54522474692b98abb9d23736
Comment 6 Christophe Marin 2017-05-02 10:09:53 UTC
So, now it crashes after Checking Collection 29 search index...

-yuuko- krop 11:58 /kde/build/5/akonadiserver # 11:58:31 - akonadiserver(5317) - org.kde.pim.akonadiplugin_indexer: : unknown term  ""
11:58:31 - akonadiserver(5317) - org.kde.pim.akonadiplugin_indexer: : unknown term  ""
11:58:31 - akonadiserver(5317) - org.kde.pim.akonadiplugin_indexer: : unknown term  ""
11:58:31 - akonadiserver(5317) -  : ASSERT failure in Akonadi::Search::Query::exec: "A query is being initialized without a type", file /kde/src/5/akonadi-search/core/query.cpp, line 227

Collection 29 is the top collection of one of my configured imap servers (the rid is imap://<my login>@mail.infomaniak.com/

#5  0x00007f5805a64141 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f57f415e06f in Akonadi::Search::Query::exec (this=0x7f57f51d9b40) at /kde/src/5/akonadi-search/core/query.cpp:227
#7  0x00007f5806b52f45 in SearchPlugin::search (this=0x7f57cc003320, akonadiQuery=..., collections=..., mimeTypes=...) at /kde/src/5/akonadi-search/akonadiplugin/searchplugin.cpp:357
#8  0x00007f5806b537c3 in non-virtual thunk to SearchPlugin::search(QString const&, QVector<long long> const&, QStringList const&) ()
   from /kde/inst/5/lib64/plugins/akonadi/akonadi_search_plugin.so
#9  0x00000000005f377f in Akonadi::Server::SearchRequest::searchPlugins (this=0x7f57f51da348) at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:111
#10 0x00000000005f390d in Akonadi::Server::SearchRequest::exec (this=0x7f57f51da348) at /kde/src/5/akonadiserver/src/server/search/searchrequest.cpp:122
#11 0x000000000058a333 in Akonadi::Server::StorageJanitor::findOprhanSearchIndexEntries (this=0xac00d0) at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:762
#12 0x000000000057ff9b in Akonadi::Server::StorageJanitor::check (this=0xac00d0) at /kde/src/5/akonadiserver/src/server/storagejanitor.cpp:135
#13 0x00000000005a0576 in Akonadi::Server::StorageJanitor::qt_static_metacall (_o=0xac00d0, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f57f51da770)
    at /kde/build/5/akonadiserver/src/server/libakonadiserver_autogen/EWIEGA46WW/moc_storagejanitor.cpp:96
#14 0x00000000005a0845 in Akonadi::Server::StorageJanitor::qt_metacall (this=0xac00d0, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f57f51da770)
    at /kde/build/5/akonadiserver/src/server/libakonadiserver_autogen/EWIEGA46WW/moc_storagejanitor.cpp:146
#15 0x00007f58062ed7e0 in QDBusConnectionPrivate::deliverCall(QObject*, int, QDBusMessage const&, QVector<int> const&, int) () from /usr/lib64/libQt5DBus.so.5
Comment 7 Christophe Marin 2017-05-02 10:40:22 UTC
A solution could be th exclude collections that have the 'noselect' attribute.
Comment 8 Christophe Marin 2017-08-15 20:54:22 UTC
I wiped everything today (data + config + db). The crash still exists in master : 

#2  0x000000000062ec9e in akMessageHandler (type=QtFatalMsg, context=..., msg=...) at /kde/src/5/akonadi/src/shared/akdebug.cpp:167
#3  0x00007f876c12409f in qt_message(QtMsgType, QMessageLogContext const&, char const*, __va_list_tag*) () from /usr/lib64/libQt5Core.so.5
#4  0x00007f876c125899 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib64/libQt5Core.so.5
#5  0x00007f876c120fea in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f875916b11f in Akonadi::Search::Query::exec (this=0x7f875b7fcb50) at /kde/src/5/akonadi-search/core/query.cpp:227
#7  0x00007f87595f1300 in SearchPlugin::search (this=0x7f8740002f70, akonadiQuery=..., collections=..., mimeTypes=...) at /kde/src/5/akonadi-search/akonadiplugin/searchplugin.cpp:357
#8  0x00007f87595f1cd3 in non-virtual thunk to SearchPlugin::search(QString const&, QVector<long long> const&, QStringList const&) () from /kde/inst/5/lib64/plugins/akonadi/akonadi_search_plugin.so
#9  0x000000000060082f in Akonadi::Server::SearchRequest::searchPlugins (this=0x7f875b7fd398) at /kde/src/5/akonadi/src/server/search/searchrequest.cpp:111
#10 0x00000000006009bd in Akonadi::Server::SearchRequest::exec (this=0x7f875b7fd398) at /kde/src/5/akonadi/src/server/search/searchrequest.cpp:122
#11 0x0000000000594175 in Akonadi::Server::StorageJanitor::findOprhanSearchIndexEntries (this=0x2753560) at /kde/src/5/akonadi/src/server/storagejanitor.cpp:762
#12 0x0000000000589dfb in Akonadi::Server::StorageJanitor::check (this=0x2753560) at /kde/src/5/akonadi/src/server/storagejanitor.cpp:135
#13 0x00000000005aa926 in Akonadi::Server::StorageJanitor::qt_static_metacall (_o=0x2753560, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f875b7fd7a0) at /kde/build/5/akonadi/src/server/libakonadiserver_autogen/EWIEGA46WW/moc_storagejanitor.cpp:96
#14 0x00000000005aabf5 in Akonadi::Server::StorageJanitor::qt_metacall (this=0x2753560, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f875b7fd7a0) at /kde/build/5/akonadi/src/server/libakonadiserver_autogen/EWIEGA46WW/moc_storagejanitor.cpp:146
Comment 9 Christophe Marin 2017-08-15 20:57:01 UTC
Created attachment 107300 [details]
full backtrace
Comment 10 Christophe Marin 2017-08-15 21:03:41 UTC
fsck still hangs on the same collection

remoteid: imap://login@domain@mail.infomaniak.com/
remoterevision: empty
syncpref: 2
displaypref: 2
indexpref: 2 referenced: false
cachepolicycheckinterval: 15
cachepolicycachetimeout: -1
cachepolicyinherit: false
cachepolicysyncondemand: true
cachepolicylocalparts: ENVELOPE HEAD RFC822
isVirtual: false
Comment 11 Christophe Marin 2017-08-15 21:07:06 UTC
There's only one thing that makes this imap resource different from others: serverside subscription is turned off.
Comment 12 Daniel Vrátil 2017-08-26 10:15:24 UTC
Git commit 471169247c395c4e866576969585ca42f429c6de by Daniel Vrátil.
Committed on 26/08/2017 at 10:14.
Pushed by dvratil into branch 'Applications/17.08'.

SearchPlugin: abort search query of unknown types

When searching Collection that has no mimetype or just inode/directory,
we cannot map this to a query type which then asserts lower in search
core code which needs a known query type.
FIXED-IN: 5.6.1

M  +3    -0    akonadiplugin/searchplugin.cpp

https://commits.kde.org/akonadi-search/471169247c395c4e866576969585ca42f429c6de