Bug 323844 - Adding foldert to imap-account gives "Duplicate entry" sql error
Summary: Adding foldert to imap-account gives "Duplicate entry" sql error
Status: REOPENED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: IMAP resource (show other bugs)
Version: 1.10.2
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Christian Mollekopf
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-21 16:37 UTC by Johannes Hirte
Modified: 2018-01-23 18:21 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Hirte 2013-08-21 16:37:02 UTC
Every time I try to create an imap-folder, akonadi fails with:

Error during executing query "INSERT INTO CollectionTable (remoteId, remoteRevision, name, parentId, resourceId, cachePolicyInherit, isVirtual) VALUES (:0, :1, :2, :3, :4, :5, :6)" :  "Duplicate entry '16-newfolder' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"

for the folder newfolder as an example. The folder is created on the imap-server. I've tested with standalone mysql server and with internal one. It is mariadb-5.5.31 if this matters.

Reproducible: Always
Comment 1 Daniel Vrátil 2013-08-22 10:43:27 UTC
Is it possible that the folder already existed on server before you tried to create it in KMail, but maybe you just weren't subscribed to it?
Comment 2 Johannes Hirte 2013-08-22 11:23:09 UTC
(In reply to comment #1)
> Is it possible that the folder already existed on server before you tried to
> create it in KMail, but maybe you just weren't subscribed to it?

No, I've tried with a complete new account that never existed neither on the imap-server nor akonadi. Creating a new, not already existing folder gives the akonadi-error.
Comment 3 Geert Janssens 2013-08-24 16:59:38 UTC
I got this very same error when trying to add an owncloud resource in akonadi, in which I have a calendar and addressbook that both use the same name (both are named 'Kobalt' in my case). Due to this error my owncloud contacts are not showing in my KAddressbook.

I could work around this issue by renaming the owncloud calendar. But the core issue is that akonadi doesn't handle duplicate resource names very well. My use case should work. A calendar and addressbook that use the same name are still easily identified as different objects. It would be more difficult for two calendars using the same name for example.
Comment 4 Daniel Vrátil 2013-08-26 17:10:33 UTC
@Geert, Akonadi by design does not allow having two subcollections with the same name in the same parent collection - this can however happen with special resources that handle various data types (like owncloud, which handles both calendars and contacts). Please open a bug report against the owncloud resource - the resource must make sure the name is unique within it's parent collection. The name that is displayed to user can be stored to EntityDisplayAttribute, so no worry that you would see one of your collections names like "Kobalt_2" or something like that.

@Johannes, can you please check in Akonadi Console -> Db Browser -> collectiontable that no collection with the name you are trying to create exists there, then try to create it and check again. If a new record with the name and remoteId filled is there, then there's some weird bug that KMail or the IMAP resource is trying to create the collections twice. Make sure you have "Debugger" enabled when creating the collection. If you get the error again, please provide entire output of the "Debugger" tab. Thanks
Comment 5 Johannes Hirte 2013-08-26 17:40:14 UTC
(In reply to comment #4)
> @Johannes, can you please check in Akonadi Console -> Db Browser ->
> collectiontable that no collection with the name you are trying to create
> exists there, then try to create it and check again. If a new record with
> the name and remoteId filled is there, then there's some weird bug that
> KMail or the IMAP resource is trying to create the collections twice.  Make
> sure you have "Debugger" enabled when creating the collection. If you get
> the error again, please provide entire output of the "Debugger" tab. Thanks

output from the "Debugger" tab:

kmail2-2005480717 (0x24c4e50) 11 CREATE "debugkmail" 46 ( REMOTEID "" REMOTEREVISION "" VIRTUAL 0 CACHEPOLICY (INHERIT true)) 
kmail2-2005480717 (0x24c4e50) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ) 
kmail2-2005480717 (0x24c4e50) 11 OK CREATE completed 
MailFilter Kernel ETM (0x24c5230) 14 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
Archive Mail Kernel ETM (0x24b4bb0) 14 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
MailFilter Kernel ETM (0x24c5230) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
MailFilter Kernel ETM (0x24c5230) 14 OK List completed 
Archive Mail Kernel ETM (0x24b4bb0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
Archive Mail Kernel ETM (0x24b4bb0) 14 OK List completed 
akonadi_newmailnotifier_agent (0x23e1680) 9 LSUB 58 0 () (ANCESTORS INF) 
akonadi_nepomuk_feeder (0x23de2d0) 9 LSUB 58 0 () () 
akonadi_newmailnotifier_agent (0x23e1680) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
akonadi_newmailnotifier_agent (0x23e1680) 9 OK List completed 
akonadi_nepomuk_feeder (0x23de2d0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ) 
akonadi_nepomuk_feeder (0x23de2d0) 9 OK List completed 
akonadi_imap_resource_5 (0x23e03b0) 51 LSUB 46 0 () (STATISTICS true ANCESTORS INF) 
akonadi_imap_resource_5 (0x23e03b0) * 46 0 (NAME "kmailtest" MIMETYPE (inode/directory) REMOTEID "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT false INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((0 "")) noselect "1") 
akonadi_imap_resource_5 (0x23e03b0) 51 OK List completed 
akonadi_imap_resource_5 (0x23e03b0) 52 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
akonadi_imap_resource_5 (0x23e03b0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
akonadi_imap_resource_5 (0x23e03b0) 52 OK List completed 
ETMCalendar (0x23d8cb0) 13 LSUB 58 0 () (ANCESTORS INF) 
ETMCalendar (0x23d8cb0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
ETMCalendar (0x23d8cb0) 13 OK List completed 
ETMCalendar (0x2407660) 13 LSUB 58 0 () (ANCESTORS INF) 
ETMCalendar (0x2407660) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
ETMCalendar (0x2407660) 13 OK List completed 
KMail Kernel ETM (0x23ecc80) 21 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
KMail Kernel ETM (0x23ecc80) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
KMail Kernel ETM (0x23ecc80) 21 OK List completed 
AkonadiConsole Browser Widget (0x2438620) 9 LSUB 58 0 () (ANCESTORS INF) 
AkonadiConsole Browser Widget (0x2438620) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
AkonadiConsole Browser Widget (0x2438620) 9 OK List completed 
akonadi_imap_resource_5 (0x23e03b0) 53 UID MODIFY 58 PARENT 46 NAME "debugkmail" REMOTEID "/debugkmail" REMOTEREVISION "" 
akonadi_imap_resource_5 (0x23e03b0) 53 OK MODIFY done 
MailFilter Kernel ETM (0x24c5230) 15 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
akonadi_nepomuk_feeder (0x23de2d0) 10 LSUB 58 0 () () 
Archive Mail Kernel ETM (0x24b4bb0) 15 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
akonadi_newmailnotifier_agent (0x23e1680) 10 LSUB 58 0 () (ANCESTORS INF) 
KMail Kernel ETM (0x23ecc80) 22 LSUB 58 0 () (STATISTICS true ANCESTORS INF) 
ETMCalendar (0x2407660) 14 LSUB 58 0 () (ANCESTORS INF) 
ETMCalendar (0x2407660) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
ETMCalendar (0x2407660) 14 OK List completed 
akonadi_nepomuk_feeder (0x23de2d0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ) 
akonadi_nepomuk_feeder (0x23de2d0) 10 OK List completed 
akonadi_newmailnotifier_agent (0x23e1680) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
akonadi_newmailnotifier_agent (0x23e1680) 10 OK List completed 
Archive Mail Kernel ETM (0x24b4bb0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
Archive Mail Kernel ETM (0x24b4bb0) 15 OK List completed 
KMail Kernel ETM (0x23ecc80) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
KMail Kernel ETM (0x23ecc80) 22 OK List completed 
ETMCalendar (0x23d8cb0) 14 LSUB 58 0 () (ANCESTORS INF) 
ETMCalendar (0x23d8cb0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
ETMCalendar (0x23d8cb0) 14 OK List completed 
MailFilter Kernel ETM (0x24c5230) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
MailFilter Kernel ETM (0x24c5230) 15 OK List completed 
AkonadiConsole Browser Widget (0x2438620) 10 LSUB 58 0 () (ANCESTORS INF) 
AkonadiConsole Browser Widget (0x2438620) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) ) 
AkonadiConsole Browser Widget (0x2438620) 10 OK List completed 
akonadi_imap_resource_5 (0x23e03b0) 54 BEGIN 
akonadi_imap_resource_5 (0x23e03b0) 54 OK Begin completed 
akonadi_imap_resource_5 (0x23e03b0) 55 LIST 0 INF (RESOURCE akonadi_imap_resource_5) (ANCESTORS 1) 
akonadi_imap_resource_5 (0x23e03b0) * 51 46 (NAME "Drafts" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".Drafts" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) timestamp "1377170263" uidnext "1" collectionflags "\\Answered \\Flagged \\Deleted \\Seen \\Draft \\*" uidvalidity "1377170199") 
akonadi_imap_resource_5 (0x23e03b0) * 49 46 (NAME "INBOX" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".INBOX" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) ENTITYDISPLAY "(\"Inbox\" \"mail-folder-inbox\" \"\" ())" timestamp "1377170263" uidnext "2" collectionflags "\\Answered \\Flagged \\Deleted \\Seen \\Draft \\*" uidvalidity "1377170198") 
akonadi_imap_resource_5 (0x23e03b0) * 47 46 (NAME "Junk" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".Junk" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) timestamp "1377170262" uidnext "1" collectionflags "\\Answered \\Flagged \\Deleted \\Seen \\Draft \\*" uidvalidity "1377170200") 
akonadi_imap_resource_5 (0x23e03b0) * 48 46 (NAME "Sent" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".Sent" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) timestamp "1377170263") 
akonadi_imap_resource_5 (0x23e03b0) * 50 46 (NAME "Trash" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".Trash" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) timestamp "1377170263") 
akonadi_imap_resource_5 (0x23e03b0) * 58 46 (NAME "debugkmail" MIMETYPE (inode/directory) REMOTEID "/debugkmail" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) ) 
akonadi_imap_resource_5 (0x23e03b0) * 56 46 (NAME "kmailfolder" MIMETYPE (inode/directory) REMOTEID "/kmailfolder" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) ) 
akonadi_imap_resource_5 (0x23e03b0) * 52 46 (NAME "newfolder" MIMETYPE (inode/directory) REMOTEID "/newfolder" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((46 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/")) ) 
akonadi_imap_resource_5 (0x23e03b0) * 46 0 (NAME "kmailtest" MIMETYPE (inode/directory) REMOTEID "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_5" VIRTUAL 0 CACHEPOLICY (INHERIT false INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) ANCESTORS ((0 "")) noselect "1") 
akonadi_imap_resource_5 (0x23e03b0) 55 OK List completed 
akonadi_imap_resource_5 (0x23e03b0) 56 UID MODIFY 46 MIMETYPE (inode/directory) PARENT 0 NAME "kmailtest" REMOTEID "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/" CACHEPOLICY (INHERIT false INTERVAL -1 CACHETIMEOUT 60 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD)) noselect "1" 
akonadi_imap_resource_5 (0x23e03b0) 56 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 57 UID MODIFY 47 MIMETYPE (message/rfc822 inode/directory) PARENT 46 NAME "Junk" REMOTEID ".Junk" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 57 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 58 UID MODIFY 48 MIMETYPE (message/rfc822 inode/directory) PARENT 46 NAME "Sent" REMOTEID ".Sent" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 58 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 59 UID MODIFY 49 MIMETYPE (message/rfc822 inode/directory) PARENT 46 NAME "INBOX" REMOTEID ".INBOX" ENTITYDISPLAY "(\"Inbox\" \"mail-folder-inbox\" \"\" ())" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 59 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 60 UID MODIFY 50 MIMETYPE (message/rfc822 inode/directory) PARENT 46 NAME "Trash" REMOTEID ".Trash" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 60 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 61 UID MODIFY 51 MIMETYPE (message/rfc822 inode/directory) PARENT 46 NAME "Drafts" REMOTEID ".Drafts" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 61 OK MODIFY done 
akonadi_imap_resource_5 (0x23e03b0) 62 CREATE "debugkmail" 46 (MIMETYPE (message/rfc822 inode/directory) REMOTEID ".debugkmail" REMOTEREVISION "" VIRTUAL 0 CACHEPOLICY (INHERIT true)) 
akonadi_imap_resource_5 (0x23e03b0) 62 NO Could not create collection debugkmail resourceId: 5 
akonadi_imap_resource_5 (0x23e03b0) 63 ROLLBACK 
akonadi_imap_resource_5 (0x23e03b0) 63 OK Rollback completed 
akonadi_imap_resource_5 (0x23e03b0) 64 HRID MODIFY ((-236 ".debugkmail") (-234 "imap://kmailtest@datenkhaos.de@mail.datenkhaos.de/") (0 "")) MIMETYPE (message/rfc822 inode/directory) NAME "debugkmail" REMOTEID ".debugkmail" timestamp "1377538574" -noselect 
akonadi_imap_resource_5 (0x23e03b0) 64 NO Hierarchical RID does not specify a unique collection
Comment 6 Daniel Vrátil 2013-08-27 17:14:31 UTC
Thanks, very useful!

Is it a well-known IMAP server (Dovecot, Cyrus,....) or some proprietary implementation?
Comment 7 Johannes Hirte 2013-08-27 19:07:07 UTC
(In reply to comment #6)
> Thanks, very useful!
> 
> Is it a well-known IMAP server (Dovecot, Cyrus,....) or some proprietary
> implementation?

It's a dovecot 2.2.5 from Gentoo. As far as I see there is only pigeonhole support added and no other patches.
Comment 8 Daniel Vrátil 2013-10-24 16:27:45 UTC
Looking through this again, it looks like there is a problem with separators (the server apparently uses "." as folder separator). This has been recently fixed, please test against 4.11.2 if you can.
Comment 9 Kevin Ottens 2013-11-16 07:29:57 UTC
The IMAP resource has a new maintainer, reassigning to him.
Comment 10 Johannes Hirte 2013-11-19 16:22:02 UTC
Creating imap-folders seems to work now, but I have to restart kmail to see them. Different Bug I assume?
Comment 11 Christian Mollekopf 2013-11-20 10:27:18 UTC
(In reply to comment #10)
> Creating imap-folders seems to work now, but I have to restart kmail to see
> them. Different Bug I assume?

That is indeed a different bug, thanks for the reports.
Comment 12 Christian Mollekopf 2014-01-20 12:43:41 UTC
I just hit this again in master:

akonadi_imap_resource_0(6071)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: "/test7"
akonadi_archivemail_agent(6063)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_notes_agent(6080)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_mailfilter_agent(6076)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_folderarchive_agent(6067)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_mailfilter_agent(6076)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_archivemail_agent(6063)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_notes_agent(6080)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
akonadi_folderarchive_agent(6067)/libakonadi Akonadi::EntityTreeModelPrivate::monitoredCollectionChanged: 115
Error during executing query "INSERT INTO CollectionTable (remoteId, remoteRevision, name, parentId, resourceId, cachePolicyInherit, isVirtual) V
ALUES (:0, :1, :2, :3, :4, :5, :6)" :  "Duplicate entry '57-test7' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statem
ent"
Error during insertion into table "CollectionTable" "Duplicate entry '57-test7' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to e
xecute statement" 

As you can see I created the folder "test7". Unfortunately this only happended once and I couldn't reproduce it so far.
Comment 13 Dennis Schridde 2015-04-03 10:15:21 UTC
I have the same issue with a trash folder.

I get a popup dialogue saying:
```
The Email program encountered a fatal error and will terminate now.
The error was:
Could not create collection trash resourceId: 5
```

On the console Akonadi logs:
```
DATABASE ERROR:
Error code: 1062
DB error:  "Duplicate entry '6-trash' for key 'CollectionTable_parentAndNameIndex'"
Error text: "Duplicate entry '6-trash' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
Query: "INSERT INTO CollectionTable (remoteId, remoteRevision, name, parentId, resourceId, enabled, syncPref, displayPref, indexPref, cachePolicyInherit, isVirtual) VALUES (:0, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10)"
Error during insertion into table "CollectionTable" "Duplicate entry '6-trash' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement" 
```

Looking at the collectiontable in akonadiconsole shows me that the collection with id 6 has resourceId 5, and that a collection with remoteId "trash" exists with parentId 6.
Comment 14 Dennis Schridde 2015-04-03 10:16:35 UTC
P.S: This is Ubuntu 14.04 with KMail 4.14.2 from the Kubuntu PPA (4:4.14.2-0ubuntu1~ubuntu14.04~ppa1).
Comment 15 Dennis Schridde 2015-04-03 10:28:32 UTC
I renamed the folder with remoteId "trash" in collection id 6 / resourceId 5 from "wastebin" to "trash" using akonadiconsole. Now KMail starts again, without showing the popup error described above.
Comment 16 Till Schäfer 2017-01-18 15:11:20 UTC
I have created a meta-bug " Akonadi IMAP Resource should handle Duplicate entry in CollectionTable errors": Bug 375244