kmail does not display local folder content after akonadi migration

I run opensuse 11.3/KDE:Factory. Recently, kmail updated to using akonadi. The following problem came up. My local emails are now managed by a “local folders” component of akonadi. The folder structure is displayed correctly in Kmail. However, no emails are shown for some folders. Emails still live in the .kde4/share/app/kmail directory hierarchy and can be imported into a new folder after moving them somewhere else. However, even after a fresh import sometimes emails are no longer recognized.

Any help appreciated and thanks in advance.

Solution: The problem was that akonadi lost the folder for the maildir hierarchy (not set in akonadi resource configuration). Still kmail is diplaying the folder hierarchy but not able to retrieve mail. After resetting the akonadi settings, emails are accessible again.

Sorry can you elaborate? Akonadi did loose by a malfunctions its settings? Or was the default setting the way you did describe? Just to understand. Are all emails accessible again? Thank you.

I think I figured it out. But, if you follow my instructions, you do it at your own risk, as always :stuck_out_tongue:

There is a whole set of problems, one leading into another, which brakes Kmail after OpenSUSE 11.4 upgraded to 12.1.

I suspect that this scenario is a rolling issue between upgrades on different distro’s that ship KDE.

So, from the top: Kmail dies. Digging dipper shows that Akonadi does not start properly. Digging dipper, Akonadi uses MySql as default internal storage. Thus, MySQL is a culprit. Further, there is more than one thing wrong with MySQL!

1st: make sure MySql starts with KDE. YaST -> System -> System services. Here, make sure MySQL is running (probably not) and go to expert mode and select MySQL to start for runlevel 5 ( I also selected 3, but probably for no good reason).

2nd: it looks like Akonadi failed to create its default database during its post-install config because… yup, MySQl was not running. I think that reinstalling Akonadi with running MySQL may solve problem from here.

Now, how I got Akonadi fixed in a quick and dirty way. I do not claim any profound understanding of this arcane art, it was merely intuition + Google.

in here, http://userbase.kde.org/Akonadi_4.4/Troubleshooting in the section “Kubuntu 10.04 (Lucid Lynx) Upgrade” I found some obscure spells, which suggest the same scenario, Akonadi is missing its default database. The instructions are for Ubuntu (a-hem), and they will not work in OpenSUSE due to more rigid restrictions for sudo. Some commands must be ran from root account. replace** user_name** with your desktop login name.
This method will most likely destroy some or all local content you had in Kmail, and contacts too. I didn’t care since I rely on IMAP and LDAP.

remove Akonadi config folder:

> rm -r /home/user_name/.local/share/akonadi

run Akonadi to rebuild default config:

> akonadictl starts

get root:

su -

create default db for Akonadi:

mysql_install_db --datadir=/home/user_name/.local/share/akonadi/db_data/

do more magic:

mysql_upgrade --socket=/home/user_name/.local/share/akonadi/db_misc/mysql.socket

if you got no errors at this point, it is possible I actually know what I am are doing

leave root:

exit

restart Akonadi:

> akonadictl stop

> akonadictl start

from this point I was able to start Kmail and restore my accounts by hand.

NB: it is reasonable to make sure that Akonadi (I have no clue where or what it is, but Alt+F2, type akonadi and select Akonadi Configuration, gets it) uses on Akonadi Server Configuration tab ‘Use Internal MySQL’ is checked and path to executable has ‘/usr/sbin/mysqld’.

good luck

Thank you for replying. The statement as of above is true for all "how-to"s and solutions in this forum, so I would not be afraid of that. I would suggest however, instead of saying “is likely to destroy your settings”, to advice to do a backup of the kde4 mail folder (as the problem with a lot of problem is the move to akonadi). It is likely that (if your solution works) at this stage you do NOT lose any of your former pop mail because Kmail Version 1 did not use akonadi at all to store mail, neither did it use AFAIK MySQL. I heard a lot of negative about MySQL and since it belongs to Oracle now, I wonder why in all world they did not set up with Postgres or MARIA database. Heaven knows. Before trying your solution, I will try to set up for Postgres, as I think problems with MySQL are only a question of time in the future.
In all cases thank you for sharing the solution, it will help not only me but also all other users. Thank you again.

P.s. Just a thing O.T. but that might be of your interest. Since you like to tweek your system: Consider to make openSUSE safer by voting for the openfate feature https://features.opensuse.org/312047. At least little by little one get problems fixed and one of the problem a lot of users encounter is that they cannot verify if a repo is safe or not because they cannot check the fingerprint of the repokey. This feature proposed in openfate tries to establish a https page where you can find with one click reliable keys of the current repos to make sure that their content is integer. Thank you for having a look. At the beginning there where only two votes, now there are 14.IMO there should be many more. I firmly belief that the proposed solution is easy to set up and very efficient.

@takiysobi:
While following your way, I am running into following error:

mysql_upgrade --socket=/home/myusername/.local/share/akonadi/db_misc/mysql.socket
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysql/mysql.sock' '--socket=/home/myusername/.local/share/akonadi/db_misc/mysql.socket' 
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/home/myusername/.local/share/akonadi/db_misc/mysql.socket' (2) when trying to connect
FATAL ERROR: Upgrade failed

I did start the service for msql beforehand. It started well. The first command gave no error, the database installed nicely. I did follow the recommendations of the program to do a secure install. It did everything without error. last step gives the mentioned error. Any suggestion?

OK, I saw that one… I wish I wrote down every step, but I was in that crazy " I am gonna tweak sh*t out of you" mode…

Make sure that you run of the root, not sudo. It is goofy how MySQl is sensitive to sudo. openSUSE (and Debian for that matter), unlike Ubuntu from which I got this solution, resolves system folders for non-privileged users.

Make sure MySQL is actually up. It took me a couple attempts to figure out how to make it auto-start in YaST.

When you try again, start from top, because I think for some reason it is important that after you delete /home/myusername/.local/share/akonadi/, then you run akonadi to rebuilt its config folder structure.

Here is another point, by default MySQL has no root password, but it may assume it does, or you may actually have one you set up before. I think I ran all MySQL scripts with options

-u root -p

and it would ask me for root’s password for MySQL. Maybe that’s it. I will try again later and see if I can replicate this (would be a good idea before making post, though)

With mail being safe in local folder, point well taken.

disregard all above, I hit the same error again and my assumptions must be wrong. I keep trying though.

well, here is what I come to thinks of as a solution. I wish it was anything else, but it must work though.

As I stated above - problem was with akonadi deprived of MySQL services. Simple, but not elegant fix to this mess would be to

  1. remove akonadi from the system
  2. make sure MySQL is up and is set to start automatically
  3. install akonadi

if it does not work right away, there may be need to delete folder /home/user_name/.local/share/akonadi manually after akonadi was uninstalled.

After all above is done and once kmail is started, it will request akonadi services and akonadi should configure itself on the first run.

given MySQL, akonadi must configure itself just fine. I have created new user in my 12.1 install, and it had kmail working, probably because I had MySQL already running. The whole thing may be happening because 11.4 had MySQL stopped by default, and 12.1 with akonadi requires it running. Update scripts must have simply missed that scenario, but this is only my vague assumption.

I do not know how it will affect contacts or local mail stored by kmail.