Bug 339214 - Starting KMail gives message "Could not create collection trash resourceId: 3 [MailCommon::Kernel::createDefaultCollectionDone, MailCommon::Kernel::emergencyExit]
Summary: Starting KMail gives message "Could not create collection trash resourceId: 3...
Status: REPORTED
Alias: None
Product: kmail2
Classification: Applications
Component: misc (show other bugs)
Version: 5.15.1
Platform: OpenSUSE Linux
: NOR crash with 21 votes (vote)
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 345399 345895 349085 350841 351213 354804 358145 358650 359461 362339 366388 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-09-19 17:05 UTC by Freek de Kruijf
Modified: 2022-08-31 14:27 UTC (History)
27 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
screenshot of window with error message in Dutch (41.41 KB, image/png)
2014-09-19 17:05 UTC, Freek de Kruijf
Details
output from "kmail >kmailoutput.txt 2>&1" (2.68 KB, text/plain)
2014-10-14 21:05 UTC, Freek de Kruijf
Details
Crash log (20.13 KB, text/vnd.kde.kcrash-report)
2021-03-23 12:44 UTC, Daniel Ziltener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Freek de Kruijf 2014-09-19 17:05:25 UTC
Created attachment 88754 [details]
screenshot of window with error message in Dutch

I tried to change the configuration of an IMAP account so pressing Del would move the message into the Trash folder of that account instead of in the Trash folder of the Local Folders, which seems to succeed. After that I started Kontact and got this error message, after which KMail/Kontact always stops.
Comment 1 Freek de Kruijf 2014-10-14 21:02:17 UTC
I got the same error while trying to configure KConfig/KMail. I have 4 IMAP accounts, of which 2 have a large number of messages, one which a small number of folders and the other with quite a lot of folders. Initially things went OK, but during retrieval of the message, the network connection went down or was not performing very well, so before retrieving all messages, KMail was stopped. Restarting it now gives the mentioned message and pressing OK ends Kontact/Kmail. So I am stuck. Starting KMail in a konsole gives the added attachment.
Comment 2 Freek de Kruijf 2014-10-14 21:05:47 UTC
Created attachment 89134 [details]
output from "kmail >kmailoutput.txt 2>&1"

output from "kmail >kmailoutput.txt 2>&1" blocks of 18 lines which are equal are removed
Comment 3 Scarlett Moore 2014-10-22 14:53:48 UTC
Testing Utopic (Kubuntu) Live session and got this error window. Unfortunately, I cannot reproduce -- restarting kontact works and the trash folder is there.
Comment 4 Freek de Kruijf 2014-10-22 20:27:46 UTC
I found a solution: remove folder ~/.local/share/local-mail/trash/
Solved my problem. There are more elaborated solutions when you google for the error message.
Comment 5 Dennis Schridde 2015-09-22 09:04:06 UTC
(In reply to Freek de Kruijf from comment #4)
> I found a solution: remove folder ~/.local/share/local-mail/trash/

I confirm, this workaround works.
Comment 6 Allen Winter 2015-09-22 12:03:24 UTC
*** Bug 345399 has been marked as a duplicate of this bug. ***
Comment 7 Gianluca Frustagli 2016-12-19 15:30:35 UTC
(In reply to Freek de Kruijf from comment #4)
> I found a solution: remove folder ~/.local/share/local-mail/trash/
> Solved my problem. There are more elaborated solutions when you google for
> the error message.

Unfortunately this didn't work for me. I had to start 'akonadiconsole', remove the 'Local Folder' agent from the agent's list and then click on the 'Restart' button.

After that it was possible to restart KMail that worked normally.

I achieved that only after a considerably amount of time searching the Internet for a solution ( https://forum.kde.org/viewtopic.php?f=215&t=120777&hilit=trash ) and I'm a good skilled Linux user.

This bug SHOULD be taken into proper consideration since it is not resolved from a long time and causes problems to users. We cannot expect normal users to browse through bug reports in order to be able to use their software, and this bug is a show stopper since it prevents people from starting the software.
Comment 8 Freek de Kruijf 2017-01-10 09:53:06 UTC
*** Bug 362339 has been marked as a duplicate of this bug. ***
Comment 9 Christoph Feck 2017-01-11 02:31:17 UTC
*** Bug 366388 has been marked as a duplicate of this bug. ***
Comment 10 Christoph Feck 2017-01-11 02:32:13 UTC
*** Bug 350841 has been marked as a duplicate of this bug. ***
Comment 11 Christoph Feck 2017-01-11 02:32:40 UTC
*** Bug 351213 has been marked as a duplicate of this bug. ***
Comment 12 Christoph Feck 2017-01-11 02:33:31 UTC
*** Bug 345895 has been marked as a duplicate of this bug. ***
Comment 13 Christoph Feck 2017-01-11 02:34:07 UTC
*** Bug 354804 has been marked as a duplicate of this bug. ***
Comment 14 Christoph Feck 2017-01-11 02:34:47 UTC
*** Bug 358650 has been marked as a duplicate of this bug. ***
Comment 15 Christoph Feck 2017-01-11 02:35:13 UTC
*** Bug 359461 has been marked as a duplicate of this bug. ***
Comment 16 Christoph Feck 2017-01-11 02:36:26 UTC
*** Bug 349085 has been marked as a duplicate of this bug. ***
Comment 17 Christoph Feck 2017-01-11 02:36:58 UTC
*** Bug 358145 has been marked as a duplicate of this bug. ***
Comment 18 Christoph Feck 2017-01-11 02:52:02 UTC
createDefaultCollectionDone() calls emergencyExit() on any error, causing a crash because of unexpected destroying of global objects.

Relevant part of the backtrace:

Thread 1 (Thread 0x7f7d948587c0 (LWP 3548)):
[KCrash Handler]
#15 0x00007f7d913f1b39 in __run_exit_handlers () at /lib64/libc.so.6
#16 0x00007f7d913f1b85 in  () at /lib64/libc.so.6
#17 0x00007f7d19436063 in MailCommon::Kernel::emergencyExit(QString const&) () at /usr/lib64/libKF5MailCommon.so.5
#18 0x00007f7d1943664a in MailCommon::Kernel::createDefaultCollectionDone(KJob*) () at /usr/lib64/libKF5MailCommon.so.5
#19 0x00007f7d91fb373f in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib64/libQt5Core.so.5
#20 0x00007f7d936135e2 in KJob::result(KJob*, KJob::QPrivateSignal) () at /usr/lib64/libKF5CoreAddons.so.5
#21 0x00007f7d93613e4f in KJob::finishJob(bool) () at /usr/lib64/libKF5CoreAddons.so.5
#22 0x00007f7d90ab8bce in  () at /usr/lib64/libKF5AkonadiCore.so.5
#23 0x00007f7d90abba28 in  () at /usr/lib64/libKF5AkonadiCore.so.5
Comment 19 Denis Kurz 2017-01-20 19:15:31 UTC
Confirmed by "popular reporting". It was reported for 5.1.3 in Bug 362339.
Comment 20 Bruno Friedmann 2017-02-09 20:57:55 UTC
I've 12 imap account each setup to move deleted message to their own trash folder.

Long ago, I was getting crash and background running kmail. To by pass this problem I've used the setting to not empty trash folder on exit, and after kmail never crashed again on exit.
Comment 21 Freek de Kruijf 2017-12-01 10:00:48 UTC
Recently the trash folder to remove is no longer ~/.local/share/local-mail/trash/ but ~/.local/share/akonadi_maildir_resource_0/trash/
You can also set it aside.
Comment 22 CnZhx 2017-12-01 11:02:44 UTC
(In reply to Freek de Kruijf from comment #21)
> Recently the trash folder to remove is no longer
> ~/.local/share/local-mail/trash/ but
> ~/.local/share/akonadi_maildir_resource_0/trash/
> You can also set it aside.

Thanks for the update.

I ran into this situation again this morning (I have not restart/shutdown my laptop for a long time). The kmail is recovered after I followed the instruction in Comment #7 "to start 'akonadiconsole', remove the 'Local Folder' agent from the agent's list and then click on the 'Restart' button".

I have not tried to remove the folder `~/.local/share/akonadi_maildir_resource_0/trash/`.
Comment 23 kde 2019-02-17 16:54:25 UTC
This still happens on KMail 5.10.2 / Frameworks 5.55.0
Comment 24 Sérgio Basto 2019-06-08 00:40:07 UTC
Hi, look likes https://forum.kde.org/viewtopic.php?t=120777

cd ~/.kde/share/apps/kmail/mail

and remove trash folder for example with :

mv trash/ ~
Comment 25 Martin Oemus 2019-11-24 14:16:37 UTC
This still happens in kmail 5.11.3, KDE Frameworks 5.64.0.

Deleting the local folder agent in aconadiconsole solves the problem.
Comment 26 Dennis Schridde 2020-03-07 23:34:10 UTC
Just ran into this again using:
* KMail 5.13.3 (19.12.3)
* KDE Frameworks 5.67.0
* Qt 5.14.1 (built against 5.14.1)
Comment 27 Daniel Ziltener 2020-10-02 00:21:25 UTC
This bug is still alive and kicking. Happens reliably every time when creating a mailbox and changing its trash folder from the local folders one to the account's IMAP folder.
Comment 28 Chris Josten 2020-11-10 16:49:34 UTC
Same problem here. I believe this Akonadi log lines have to do something with it:

org.kde.pim.akonadiserver: DATABASE ERROR:
org.kde.pim.akonadiserver:   Error code: "1062"
org.kde.pim.akonadiserver:   DB error:  "Duplicate entry '6-trash' for key 'CollectionTable_parentAndNameIndex'"
org.kde.pim.akonadiserver:   Error text: "Duplicate entry '6-trash' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
org.kde.pim.akonadiserver:   Values: QMap((":0", QVariant(QString, ""))(":1", QVariant(QString, ""))(":10", QVariant(int, -1))(":11", QVariant(int, -1))(":12", QVariant(bool, false))(":13", QVariant(QString, ""))(":14", QVariant(bool, false))(":2", QVariant(QString, "trash"))(":3", QVariant(qlonglong, 6))(":4", QVariant(qlonglong, 4))(":5", QVariant(bool, true))(":6", QVariant(int, 2))(":7", QVariant(int, 2))(":8", QVariant(int, 2))(":9", QVariant(bool, true)))
org.kde.pim.akonadiserver:   Query: "INSERT INTO CollectionTable (remoteId, remoteRevision, name, parentId, resourceId, enabled, syncPref, displayPref, indexPref, cachePolicyInherit, cachePolicyCheckInterval, cachePolicyCacheTimeout, cachePolicySyncOnDemand, cachePolicyLocalParts, isVirtual) VALUES (:0, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14)"
org.kde.pim.akonadiserver: Error during insertion into table "CollectionTable" "Duplicate entry '6-trash'
Comment 29 Sérgio Basto 2020-11-10 17:11:40 UTC
have you tried solution on https://bugs.kde.org/show_bug.cgi?id=339214#c24 ?
Comment 30 Daniel Ziltener 2020-12-29 14:05:08 UTC
(In reply to Sérgio Basto from comment #29)
> have you tried solution on https://bugs.kde.org/show_bug.cgi?id=339214#c24 ?

That's not a solution, that's a workaround at best.
Comment 31 Daniel Ziltener 2021-03-23 12:44:51 UTC
Created attachment 136981 [details]
Crash log
Comment 32 MoritzD 2021-11-22 13:16:15 UTC
Hi, I got the same problem. For me the solution of CnZhx  2017-12-01 11:02:44 UTC worked: "start 'akonadiconsole', remove the 'Local Folder' agent from the agent's list"

Please change this misleading error message. Especially I hate alert-messages with only one "accept"-button and modal windows in general. If there's a broken e-mail account kmail2 should start anyway complaining later. Nobody understands why a "collection trash" is that important the program doesn't starts at all.

Instead of akonadiconsole kmail2 should cure this problem from within.
Comment 33 Dave 2021-12-16 11:30:13 UTC
I have just run into this bug just by pointing my trashes off the local trash to respective IMAP located trash folders.
There are many people affected, several bug duplicates, and the status is still only "REPORTED" ... since 2014?
Comment 34 Fabian Vogt 2022-07-19 14:51:40 UTC
My Akonadi suddenly (no config changes) developed the same issue. KMail refuses to start because of "Could not create collection 'drafts'". The issue appears to be that the "drafts" collection had the "SpecialCollectionAttribute" set to "trash", with a matching icon, while "trash" also had that. As it couldn't find a proper "drafts" collection it tried to create "drafts" again. Using akonadiconsole I could fix the "SpecialCollectionAttribute" of the collection and KMail works for me again. Question is why the attribute changed.
Comment 35 Celeste Wouters 2022-08-31 12:29:00 UTC
Can reproduce on my machine, with a fresh new user profile, and KMail configured with one IMAP profile (which worked the first time).
"Could not create collection drafts, resourceId 4"
KMail 5.20.3 (22.04.3)
Akonadi 22.04.3
MariaDB 10.5.10
KF 5.96.0
Qt 5.15.5
Void Linux
Comment 36 Sérgio Basto 2022-08-31 14:27:18 UTC
check my comment #24 https://bugs.kde.org/show_bug.cgi?id=339214#c24