Bug 371570 - Duplicate entry in CollectionTable when creating database in a new installation
Summary: Duplicate entry in CollectionTable when creating database in a new installation
Status: RESOLVED WORKSFORME
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: 5.3.0
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-24 12:04 UTC by Antonio Larrosa
Modified: 2022-10-23 03:12 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Logs from akonadi/kmail, showing the problem (75.63 KB, text/plain)
2016-10-24 12:04 UTC, Antonio Larrosa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Larrosa 2016-10-24 12:04:21 UTC
On a clean openSUSE Leap 42.2 RC1 system (with kmail 5.3.0 and akonadi-server 16.08.2), I run kmail for the first time. It shows a "Starting Akonadi server" message for some seconds, then a dialog appears to "Provide personal data" (full name, email and password), and practically at the same time I get an error box from kmail that says:
"The Email program encountered a fatal error and will terminate now.
The error was:
Could not create collection inbox, resourceId: 3"

I ran kmail with full logs as dvratil suggested and got the attached output. That gave lots of information, and the directed to the real problem:
----
log_akonadiserver: DATABASE ERROR:
log_akonadiserver:   Error code: 1062
log_akonadiserver:   DB error:  "Duplicate entry '4-inbox' for key 'CollectionTable_parentAndNameIndex'"
log_akonadiserver:   Error text: "Duplicate entry '4-inbox' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
log_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)"
log_akonadiserver: Error during insertion into table "CollectionTable" "Duplicate entry '4-inbox' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
log_akonadicore: Failed SpecialCollectionsRequestJob::slotResult "Could not create collection inbox, resourceId: 3"
log_mailcommon: "The Email program encountered a fatal error and will terminate now.\nThe error was:\nCould not create collection inbox, resourceId: 3"
----

I can reproduce the problem every time, by removing the config files for the user and starting kmail again. Btw, note that if instead of starting kmail, I run akonadictl start and then kmail once akonadi is started, then there's no problem.

Reproducible: Always
Comment 1 Antonio Larrosa 2016-10-24 12:04:57 UTC
Created attachment 101739 [details]
Logs from akonadi/kmail, showing the problem
Comment 2 Daniel Vrátil 2016-10-26 21:44:41 UTC
Just an update on what I found so far:

Turns out it's a race condition between KMail and KMail :-) Specifically there seem to be two SpecialCollectionsRequestJobs started in quick succession from two different places in KMail and both attempt to create the "inbox" folder.

It's rather hard to debug where the SCRJs are started from because gdb slows down kmail enough to make the race condition go away. Setting a bp on CollectionCreateJob does not hide the race condition, but also does not provide any useful information.

I guess the best course of action is to add some debug info into SCRJ and compile AkonadiCore in the VM where I can reproduce the condition...
Comment 3 Till Schäfer 2017-01-18 15:11:05 UTC
I have created a meta-bug " Akonadi IMAP Resource should handle Duplicate entry in CollectionTable errors": Bug 375244
Comment 4 Justin Zobel 2022-09-22 12:29:35 UTC
Thank you for reporting this crash in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the crash with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 5 Bug Janitor Service 2022-10-07 04:51:05 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2022-10-22 05:01:04 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 7 Sérgio Basto 2022-10-23 03:12:00 UTC
I think this should be close as duplicated of https://bugs.kde.org/show_bug.cgi?id=339214