Bug 375244

Summary: Akonadi IMAP Resource should handle "Duplicate entry in CollectionTable" errors
Product: [Frameworks and Libraries] Akonadi Reporter: Till Schäfer <till2.schaefer>
Component: IMAP resourceAssignee: Christian Mollekopf <chrigi_1>
Status: REPORTED ---    
Severity: normal CC: evgom.sid, kdepim-bugs, sergio, vkrause
Priority: NOR    
Version: 5.4.1   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Till Schäfer 2017-01-18 15:09:23 UTC
Problem: Akonadi logging shows the below error and 
* silently fails to sync any IMAP folder-tree changes 
* does not sync any mails inside the affected folder anymore

org.kde.pim.akonadiserver: DATABASE ERROR:
org.kde.pim.akonadiserver:   Error code: 1062
org.kde.pim.akonadiserver:   DB error:  "Duplicate entry '70-2017-bwinf' for key 'CollectionTable_parentAndNameIndex'"
org.kde.pim.akonadiserver:   Error text: "Duplicate entry '70-2017-bwinf' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
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)"

Trigger: In this concrete situation, I had an unsubscribed folder on the server side and created a new folder with the same name on the client. However, there are other triggers two such as in Bug 371570, Bug 323844, or in situations where a local folder is created in offline mode and another folder is created on the server side on the same time. 

Proposed Solution: 
It seems to me, that the above described situation is not avoidable in all cases. Therefore, Akonadi/IMAP Resource must handle such situations. I would like to see some type of merge/rename dialog in this case, that allows to rename the local/remote folder or merge the content of the folders. 

The minimum solution would be to notify the user about an inconsistent state, because the inconsistent state is dangerous and can cause data loss, if the user is unaware that mails/folders are not synced to the server anymore and still uses the instance.
Comment 1 Erick Osorio 2018-01-23 20:52:50 UTC
What happen with this?

I had a lot of this errors when I change the name of account, and then I select the Trash Folder.