Sometimes Kontact crashes during startup with the following message:
"The Email program encountered a fatal error and will terminate now. The error was: Unable to retrieve collection for listing"
In the debug output we see various errors:
[1116] Akonadi server is now operational. [1440] QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave. [960] QDBusObjectPath: invalid path "" [1932] list is empty [1232] QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave. [1232] QSystemTrayIcon::setVisible: No Icon set [2652] kontact(2652) void __thiscall MessageList::Widget::slotTagsFetched(class KJob *): Failed to load tags "Unable to list tags" [2652] kontact(2652)/libakonadi void __thiscall Akonadi::EntityTreeModelPrivate::collectionFetchJobDone(class KJob *): Job error: "Unable to retrieve collection for listing" for collection: () [2652] [2652] kontact(2652) void __thiscall MailCommon::FilterManager::slotFinishedTagListing(class KJob *): failed to retrieve tags "Unable to list tags" [2652] kontact(2652)/libakonadi void __thiscall Akonadi::EntityTreeModelPrivate::collectionFetchJobDone(class KJob *): Job error: "Unable to retrieve collection for listing" for collection: () [2652] [2652] kontact(2652) void __thiscall KMail::TagActionManager::finishedTagListing(class KJob *): "Unable to list tags" [2652] kontact(2652)/libakonadi void __thiscall Akonadi::DefaultResourceJob::slotResult(class KJob *): "Unable to retrieve collection for listing" [2652] kontact(2652)/libakonadi void __thiscall Akonadi::SpecialCollectionsRequestJob::slotResult(class KJob *): Failed SpecialCollectionsRequestJob::slotResult "Unable to retrieve collection for listing" [2652] kontact(2652) void __thiscall MailCommon::Kernel::emergencyExit(const class QString &): "The Email program encountered a fatal error and will terminate now. [2652] The error was: [2652] Unable to retrieve collection for listing" [1932] list is empty
The crash is triggered by a collectionfetchjob failing (which shouldn't happen).
The underlying cause of that can be seen in akonadiservererror.log:
Database error: Cannot open database. Last driver error: "QMYSQL: Unable to connect" Last database error: "Lost connection to MySQL server at 'reading initial communication packet', system error: 10038" Database error: Cannot open database. Last driver error: "QMYSQL: Unable to connect" Last database error: "Lost connection to MySQL server at 'reading authorization packet', system error: 0" DATABASE ERROR: Error code: -1 DATABASE ERROR: DB error: "" Error code: -1 Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable LEFT JOIN CollectionMimeTypeRelation ON ( Collection_id = CollectionTable.id ) WHERE ( ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) AND MimeType_id IN ( :2 ) ) GROUP BY CollectionTable.id" Error text: " " Query: "SELECT TagTable.id, TagTable.gid, TagTable.parentId, TagTable.typeId, TagTypeTable.name FROM TagTable INNER JOIN TagTypeTable ON ( TagTable.typeId = TagTypeTable.id ) ORDER BY TagTable.id DESC" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable WHERE ( CollectionTable.parentId IS NULL AND ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) )" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " DATABASE ERROR: Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable LEFT JOIN CollectionMimeTypeRelation ON ( Collection_id = CollectionTable.id ) WHERE ( ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) AND MimeType_id IN ( :2 ) ) GROUP BY CollectionTable.id" Error code: -1 DB error: "" Error text: " " DATABASE ERROR: Query: "SELECT agTable.id, TagTable.gid, TagTable.parentId, TagTable.typeId, TagTypeTable.name FROM TagTable INNER JOIN TagTypeTable ON ( TagTable.typeId = TagTypeTable.id ) ORDER BY TagTable.id DESC" DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable WHERE ( CollectionTable.parentId IS NULL AND ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) )" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT TagTable.id, TagTable.gid, TagTable.parentId, TagTable.typeId, TagTypeTable.name FROM TagTable INNER JOIN TagTypeTable ON ( TagTable.typeId = TagTypeTable.id ) ORDER BY TagTable.id DESC" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable LEFT JOIN CollectionMimeTypeRelation ON ( Collection_id = CollectionTable.id ) WHERE ( ( CollectionTable.displayPref = :0 OR ( CollectionTable.displayPref = :1 AND CollectionTable.enabled = :2 ) OR CollectionTable.referenced = :3 ) AND MimeType_id IN ( :4 ) ) GROUP BY CollectionTable.id" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable LEFT JOIN CollectionMimeTypeRelation ON ( Collection_id = CollectionTable.id ) WHERE ( ( CollectionTable.displayPref = :0 OR ( CollectionTable.displayPref = :1 AND CollectionTable.enabled = :2 ) OR CollectionTable.referenced = :3 ) AND MimeType_id IN ( :4 ) ) GROUP BY CollectionTable.id" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable WHERE ( ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) AND CollectionTable.resourceId = :2 )" DATABASE ERROR: Error code: -1 DB error: "" Error text: " " Query: "SELECT CollectionTable.id, CollectionTable.remoteId, CollectionTable.remoteRevision, CollectionTable.name, CollectionTable.parentId, CollectionTable.resourceId, CollectionTable.enabled, CollectionTable.syncPref, CollectionTable.displayPref, CollectionTable.indexPref, CollectionTable.referenced, CollectionTable.cachePolicyInherit, CollectionTable.cachePolicyCheckInterval, CollectionTable.cachePolicyCacheTimeout, CollectionTable.cachePolicySyncOnDemand, CollectionTable.cachePolicyLocalParts, CollectionTable.queryString, CollectionTable.queryAttributes, CollectionTable.queryCollections, CollectionTable.isVirtual FROM CollectionTable WHERE ( ( CollectionTable.enabled = :0 OR CollectionTable.referenced = :1 ) AND CollectionTable.resourceId = :2 )"
Apparently akonadi fails to connect to mysql, and consequently the fetchjobs are failing.