This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Kmail error on start

Tags: None
(comma "," separated)
bartvaes
Registered Member
Posts
10
Karma
0

Kmail error on start

Mon Apr 05, 2021 12:34 pm
Hello,

I created some new IMAP identities / accounts in KMail, but suddenly I get following error when starting KMail:
The Email program encountered a fatal error and will terminate now.
The error was: Could not create collection trash, resourceId 4


This happened after I shut down KMail, and later tried to start it again but noticed the old process was still running in the background. I then killed the both processes through task manager. Is there an easy fix for this ?

EDIT: forgot to add: this error also pops up when opening Kontact, so it's not limited to KMail.

TIA,
Bart.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Mon Apr 05, 2021 3:09 pm
Hi!

You need to provide more information. Which distribution you use, what the logs say, akonadis status, etc. It could just be wrong permission setting, normally »achieved« using `sudo` with graphical tools which you should never ever do. Check it with
Code: Select all
find $HOME ! -user $USER -ls

No output is good output. If anything is listed, correct the permissions.
bartvaes
Registered Member
Posts
10
Karma
0

Re: Kmail error on start

Mon Apr 05, 2021 7:33 pm
Hey, thanks for your reply.

I doubt it's a permission problem, I got KMail up and running for a day or 2 until the program didn't shut down properly or something, and the troubles began.
Anyway, here's some output I gathered:

Permission check:
Code: Select all
bart@localhost:~/Music> find $HOME ! -user $USER -ls
bart@localhost:~/Music>


Akonadi status:
Code: Select all
bart@localhost:~> akonadictl status
Akonadi Control: running
Akonadi Server: running
Akonadi Server Search Support: available (Remote Search, Akonadi Search Plugin)
Available Agent Types: akonadi_akonotes_resource, akonadi_archivemail_agent, akonadi_birthdays_resource, akonadi_contacts_resource, akonadi_davgroupware_resource, akonadi_ews_resource, akonadi_ewsmta_resource, akonadi_followupreminder_agent, akonadi_googlecalendar_resource, akonadi_googlecontacts_resource, akonadi_ical_resource, akonadi_icaldir_resource, akonadi_imap_resource, akonadi_indexing_agent, akonadi_kalarm_dir_resource, akonadi_kalarm_resource, akonadi_knut_resource, akonadi_kolab_resource, akonadi_maildir_resource, akonadi_maildispatcher_agent, akonadi_mailfilter_agent, akonadi_mbox_resource, akonadi_migration_agent, akonadi_mixedmaildir_resource, akonadi_newmailnotifier_agent, akonadi_notes_agent, akonadi_notes_resource, akonadi_openxchange_resource, akonadi_pop3_resource, akonadi_sendlater_agent, akonadi_tomboynotes_resource, akonadi_unifiedmailbox_agent, akonadi_vcard_resource, akonadi_vcarddir_resource
bart@localhost:~>


System info: (through neofetch)
Code: Select all
bart@localhost:~/Music> neofetch
bart@localhost.localdomain
--------------------------
OS: openSUSE Leap 15.2 x86_64
Kernel: 5.3.18-lp152.68-preempt
Uptime: 11 hours, 6 mins
Packages: 3662 (rpm)
Shell: bash 4.4.23
Resolution: 1920x1080
DE: KDE
WM: KWin
WM Theme: Gently-Blur
Theme: Breeze Dark [KDE], Breeze [GTK2/3]
Icons: Breeze-Blur-Glassy Dark [KDE], Breeze-Blur-Glassy Dark [GTK2/3]
Terminal: konsole
CPU: AMD FX-6300 (6) @ 3.500GHz
GPU: AMD ATI Radeon 540/540X/550/550X / RX 540X/550/550X
Memory: 2720MiB / 7935MiB
bart@localhost:~/Music>


var/log/messages.txt output
Code: Select all
2021-04-05T15:43:43.399661+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7fa1940348e0) identified as "FilterManagerTagMonitor - 93921430476368"
2021-04-05T15:43:43.606156+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: New notification connection (registered as Akonadi::Server::NotificationSubscriber(0x7fa1940dab50) )
2021-04-05T15:43:43.617714+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7fa1940dab50) identified as "MessageListTagCacheMonitor - 139802661910544"
2021-04-05T15:43:43.954264+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver.search: Executing search "kmail2-48271-SearchSession"
2021-04-05T15:43:43.954566+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver.search: Search  "kmail2-48271-SearchSession" done (without remote search)
2021-04-05T15:43:43.961168+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: DATABASE ERROR:
2021-04-05T15:43:43.961455+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver:   Error code: "1062"
2021-04-05T15:43:43.961632+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver:   DB error:  "Duplicate entry '4-trash' for key 'CollectionTable_parentAndNameIndex'"
2021-04-05T15:43:43.961810+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver:   Error text: "Duplicate entry '4-trash' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
2021-04-05T15:43:43.961979+02:00 localhost akonadiserver[17580]: 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, 4))(":4", QVariant(qlonglong, 4))(":5", QVariant(bool, true))(":6", QVariant(int, 2))(":7", QVariant(int, 2))(":8", QVariant(int, 2))(":9", QVariant(bool, true)))
2021-04-05T15:43:43.962163+02:00 localhost akonadiserver[17580]: 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)"
2021-04-05T15:43:43.962353+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Error during insertion into table "CollectionTable" "Duplicate entry '4-trash' for key 'CollectionTable_parentAndNameIndex' QMYSQL3: Unable to execute statement"
2021-04-05T15:43:43.962532+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Failed to append Collection "trash" in resource "akonadi_maildir_resource_0"
2021-04-05T15:43:43.962703+02:00 localhost kmail[24301]: org.kde.pim.akonadicore: Failed SpecialCollectionsRequestJob::slotResult "Could not create collection trash, resourceId 4"
2021-04-05T15:43:43.962910+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Error while handling command CreateCollection on connection kmail2-48271 (0x5567ec21e6c0)
2021-04-05T15:43:43.963111+02:00 localhost kmail[24301]: org.kde.pim.mailcommon: "The Email program encountered a fatal error and will terminate now.\nThe error was:\nCould not create collection trash, resourceId 4"
2021-04-05T15:43:43.974339+02:00 localhost kwin_x11[2286]: file:///usr/share/kwin/aurorae/MenuButton.qml:22: TypeError: Type error
2021-04-05T15:43:43.991285+02:00 localhost kwin_x11[2286]: message repeated 3 times: [ file:///usr/share/kwin/aurorae/MenuButton.qml:22: TypeError: Type error]
2021-04-05T15:43:43.996154+02:00 localhost kwin_x11[2286]: QPainter::begin: Paint device returned engine == 0, type: 3
2021-04-05T15:43:46.164521+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "MessageListTagCacheMonitor - 139802661910544" disconnected
2021-04-05T15:43:46.167302+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "SpecialCollectionsMonitor - 93921427998528" disconnected
2021-04-05T15:43:46.192928+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "TagActionManagerMonitor - 93921432588176" disconnected
2021-04-05T15:43:46.193265+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "FilterManagerTagMonitor - 93921430476368" disconnected
2021-04-05T15:43:46.203707+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "KMail Kernel ETM - 93921427775104" disconnected
2021-04-05T15:43:46.204151+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "MessageViewerMonitor - 93921427835904" disconnected
2021-04-05T15:43:46.204761+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: Subscriber "MessageListTagMonitor - 93921429366832" disconnected
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Mon Apr 05, 2021 8:19 pm
logfile wrote:2021-04-05T15:43:43.961632+02:00 localhost akonadiserver[17580]: org.kde.pim.akonadiserver: DB error: "Duplicate entry '4-trash' for key 'CollectionTable_parentAndNameIndex'"
...
2021-04-05T15:43:43.963111+02:00 localhost kmail[24301]: org.kde.pim.mailcommon: "The Email program encountered a fatal error and will terminate now.\nThe error was:\nCould not create collection trash, resourceId 4"

There is a problem with mysql for your resourceID4. The first thing to try would be running
Code: Select all
akonadictl fsck
# and perhaps
akonadictl vacuum
akonadictl restart
to see if it could repair itself.

If not, there is a possibility to try different things. One would be to work in the mariaDB/mysqlDB directly using
Code: Select all
mysql --socket=/run/user/$UID/akonadi/mysql.socket
and try to fix it manually. For this I suggest you to have an actual backup and create a new user copying the old one without caching data and working there to have a simple way back.
bartvaes
Registered Member
Posts
10
Karma
0

Re: Kmail error on start

Tue Apr 06, 2021 9:28 pm
Thanks for the suggestions. Unfortunately, the akonadi commands didn't fix the problem.
I managed to connect to that mysql socket and query / list some tables and data, but I have no clue where to go from there...

Some output:
Code: Select all
MariaDB [akonadi]> show tables;
+----------------------------------+
| Tables_in_akonadi                |
+----------------------------------+
| collectionattributetable         |
| collectionmimetyperelation       |
| collectionpimitemrelation        |
| collectiontable                  |
| flagtable                        |
| mimetypetable                    |
| parttable                        |
| parttypetable                    |
| pimitemflagrelation              |
| pimitemtable                     |
| pimitemtagrelation               |
| relationtable                    |
| relationtypetable                |
| resourcetable                    |
| schemaversiontable               |
| tagattributetable                |
| tagremoteidresourcerelationtable |
| tagtable                         |
| tagtypetable                     |
+----------------------------------+
19 rows in set (0,001 sec)


And since the error log mentioned 'CollectionTable':
Code: Select all
MariaDB [akonadi]> describe collectiontable;
+--------------------------+------------------+------+-----+---------+----------------+
| Field                    | Type             | Null | Key | Default | Extra          |
+--------------------------+------------------+------+-----+---------+----------------+
| id                       | bigint(20)       | NO   | PRI | NULL    | auto_increment |
| remoteId                 | varbinary(255)   | YES  |     | NULL    |                |
| remoteRevision           | varbinary(255)   | YES  |     | NULL    |                |
| name                     | varbinary(255)   | NO   |     | NULL    |                |
| parentId                 | bigint(20)       | YES  | MUL | NULL    |                |
| resourceId               | bigint(20)       | NO   | MUL | NULL    |                |
| enabled                  | tinyint(1)       | NO   | MUL | 1       |                |
| syncPref                 | tinyint(4)       | YES  | MUL | 2       |                |
| displayPref              | tinyint(4)       | YES  | MUL | 2       |                |
| indexPref                | tinyint(4)       | YES  | MUL | 2       |                |
| cachePolicyInherit       | tinyint(1)       | NO   |     | 1       |                |
| cachePolicyCheckInterval | int(11)          | NO   |     | -1      |                |
| cachePolicyCacheTimeout  | int(11)          | NO   |     | -1      |                |
| cachePolicySyncOnDemand  | tinyint(1)       | NO   |     | 0       |                |
| cachePolicyLocalParts    | varbinary(255)   | YES  |     | NULL    |                |
| queryString              | varbinary(32768) | YES  |     | NULL    |                |
| queryAttributes          | varbinary(255)   | YES  |     | NULL    |                |
| queryCollections         | varbinary(255)   | YES  |     | NULL    |                |
| isVirtual                | tinyint(1)       | YES  |     | 0       |                |
+--------------------------+------------------+------+-----+---------+----------------+
19 rows in set (0,002 sec)


Code: Select all
MariaDB [akonadi]> select id, remoteId, name, resourceId, enabled from collectiontable where parentId = 4;
+----+-----------+-----------+------------+---------+
| id | remoteId  | name      | resourceId | enabled |
+----+-----------+-----------+------------+---------+
| 12 | drafts    | drafts    |          4 |       1 |
| 11 | inbox     | inbox     |          4 |       1 |
|  5 | outbox    | outbox    |          4 |       1 |
|  6 | sent-mail | sent-mail |          4 |       1 |
| 14 | templates | templates |          4 |       1 |
| 13 | trash     | trash     |          4 |       1 |
+----+-----------+-----------+------------+---------+
6 rows in set (0,001 sec)
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Wed Apr 07, 2021 12:02 pm
Can you check the ouptut of `select id,remoteId,parentId,resourceId from collectiontable where name='trash';`? I cannot see a duplicate entry in your output.

As it is the trashbin of your (imap)-account, you could perhaps just remove it or disable the full ID 4.
bartvaes
Registered Member
Posts
10
Karma
0

Re: Kmail error on start

Wed Apr 07, 2021 4:39 pm
koffeinfriedhof wrote:Can you check the ouptut of `select id,remoteId,parentId,resourceId from collectiontable where name='trash';`? I cannot see a duplicate entry in your output.

As it is the trashbin of your (imap)-account, you could perhaps just remove it or disable the full ID 4.


Hmm... no duplicate to be found here :-\ which is actually weird, I thought we were on to something.
Code: Select all
MariaDB [akonadi]> select id, remoteId, parentId, resourceId, enabled from collectiontable where name='trash';
+----+----------+----------+------------+---------+
| id | remoteId | parentId | resourceId | enabled |
+----+----------+----------+------------+---------+
| 13 | trash    |        4 |          4 |       1 |
+----+----------+----------+------------+---------+
1 row in set (0,001 sec)

I suppose it's safe to flip 'enabled' to 0, just to check if it fixes anything ?
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Wed Apr 07, 2021 5:55 pm
Do you have a manually installed mysql/mariadb on this system too? Seems like the database itself does not know this error, at least not at this socket/database/table.

Did you log the output of akonadictl fsck?
bartvaes
Registered Member
Posts
10
Karma
0

Re: Kmail error on start

Wed Apr 07, 2021 9:39 pm
koffeinfriedhof wrote:Do you have a manually installed mysql/mariadb on this system too? Seems like the database itself does not know this error, at least not at this socket/database/table.

Did you log the output of akonadictl fsck?

No, no other mysql instances or databases that I installed manually.
I didn't record fsck output the first time, didn't seem to be anything special in it...
I just ran it again now and it gives:
Code: Select all
Collection "Search" (id: 1) has no RID.
Collection "OpenInvitations" (id: 88) has no RID.
Collection "DeclinedInvitations" (id: 89) has no RID.
Found 3 collections without RID.
Found 0 items without RID.
Found 0 dirty items.

I re-installed akonadi-server and Kmail (without deleting anything under $HOME/) but that didn't change anything either.

However I did found out today, in directory $HOME/.config/akonadi there's 1 file constantly being deleted and re-written.
Filename = agent_config_akonadi_imap_resource_2, which corresponds with one of my IMAP accounts?
It's the only one that does that, not sure why...

Thanks for hanging on !
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Thu Apr 08, 2021 4:06 pm
Okay. I really do not know why. Is it an IMAP-account? Then you could just delete it and add it as a new one if the mails are left on the server. But I remember a lot of hassle with gmail-accounts over the past years.
Sorry to have no ideas left ;)
bartvaes
Registered Member
Posts
10
Karma
0

Re: Kmail error on start  Topic is solved

Fri Apr 09, 2021 11:25 am
koffeinfriedhof wrote:Okay. I really do not know why. Is it an IMAP-account? Then you could just delete it and add it as a new one if the mails are left on the server. But I remember a lot of hassle with gmail-accounts over the past years.
Sorry to have no ideas left ;)

They're 2 non-Gmail IMAP accounts yes, but I think I solved it now :D
I found an older thread on the web that kinda described the same problem. The 'solution' was to go to folder $HOME/.local/share/akonadi_maildir_resource_0/
where the last foldername matches the resource name (resourceId 4 from my query). There you'll see the Local Folders (I suppose) and I just renamed 'trash' to 'trash_REN'.
So now the trash folder was re-created on KMail startup, and all is good.

Oh, and the other weird thing with the "agent_config_akonadi_imap_resource_2" file being re-written constantly, was due to a wrong password in my settings for that account.

Thanks for all the suggestions though, I learned something new at least ;D Appreciate it!
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Kmail error on start

Fri Apr 09, 2021 12:14 pm
bartvaes wrote:Thanks for all the suggestions though, I learned something new at least ;D Appreciate it!

me too. Thanks for sharing the solution! Renaming a folder is a good to know idea ;)
SchoolGuy
Registered Member
Posts
3
Karma
0
OS

Re: Kmail error on start

Wed Mar 09, 2022 7:30 am
I had a nearly identical problem and the proposed solution worked like a charm. Thanks for documenting it!
megadoodoo
Registered Member
Posts
1
Karma
0
OS

Re: Kmail error on start

Thu Nov 17, 2022 4:27 pm
IN A NUTSHELL
Code: Select all
$ cat $HOME/.config/akonadi_maildir_resource_0rc
[General]
Path[$e]=$HOME/.local/share/local-mail       ### <--- go to here
TopLevelIsContainer=true

$ cd $HOME/.local/share/local-mail

$ ls
cur  drafts  inbox  new  nohup.out  outbox  sent-mail  templates  tmp  trash

$ mv trash trash_loc


IN DETAIL

I faced the same problem after I changed the `Trash folder` in my IMAP profile.
Name of `Trash folder` on server was the same as local `Trash folder`. So I see an error message on every startup of kmail and then kmail crushes.
Solution suggested by bartvaes was not suitable for the KDE5. But it was useful to find out the correct solution.

bartvaes wrote:The 'solution' was to go to folder $HOME/.local/share/akonadi_maildir_resource_0/
where the last foldername matches the resource name (resourceId 4 from my query). There you'll see the Local Folders (I suppose) and I just renamed 'trash' to 'trash_REN'.


In KDE5 now akonadi_maildir_resource_0 is just a file not a dir.
Code: Select all
$ find ~ -iregex ".*akonadi_maildir.*"
$HOME/.config/akonadi/agent_config_akonadi_maildir_resource_0
$HOME/.config/akonadi/agent_config_akonadi_maildir_resource_0_changes.dat
$HOME/.config/akonadi_maildir_resource_0rc


akonadi_maildir_resource_0 contains nothing useful.
Code: Select all
$ cat $HOME/.config/akonadi/agent_config_akonadi_maildir_resource_0
[Agent]
DesiredOnlineState=true
Name=\x41b\x43e\x43a\x430\x43b\x44c\x43d\x44b\x435 \x43f\x430\x43f\x43a\x438


akonadi_maildir_resource_0rc contains path to the DB tree.
Code: Select all
$ cat $HOME/.config/akonadi_maildir_resource_0rc
[General]
Path[$e]=$HOME/.local/share/local-mail       ### <--- DB tree path
TopLevelIsContainer=true


I go to $HOME/.local/share/local-mail and then rename the `Trash folder`: trash --> trash_loc.

I have next versions of packets:
plasmashell 5.20.5
akonadictl 5.15.3 (20.08.3)
kmail2 5.15.3 (20.08.3)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]