Ubuntu – Why does Akonadi on KDE 4.6.0 refuse to start

10.10kdekmailkubuntu

Akonadi refuses to start on my fresh installation of KDE 4.6.0 from the kubuntu-backports PPA on Ubuntu 10.10 Maverick Meerkat, preventing me from usking KMail. Here is the full error output:

patches@pleistocene:~/.local/share$ akonadictl start
Starting Akonadi Server...
   done.
patches@pleistocene:~/.local/share$ Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
search paths:  ("/home/patches/bin", "/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/usr/games", "/usr/sbin", "/usr/local/sbin", "/usr/local/libexec", "/usr/libexec", "/opt/mysql/libexec", "/opt/local/lib/mysql5/bin", "/opt/mysql/sbin") 
Found mysql_install_db:  "/usr/bin/mysql_install_db" 
Found mysqlcheck:  "/usr/bin/mysqlcheck" 
Database process exited unexpectedly during initial connection!
executable: "/usr/sbin/mysqld-akonadi"
arguments: ("--defaults-file=/home/patches/.local/share/akonadi//mysql.conf", "--datadir=/home/patches/.local/share/akonadi/db_data/", "--socket=/home/patches/.local/share/akonadi/socket-pleistocene/mysql.socket")
stdout: ""
stderr: "Could not open required defaults file: /home/patches/.local/share/akonadi//mysql.conf
Fatal error in defaults handling. Program aborted
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld-akonadi: Can't find file: './mysql/plugin.frm' (errno: 13)
110209 16:41:12 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110209 16:41:12  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
"
exit code: 1
process error: "Unknown error"
"[
0: akonadiserver(_Z11akBacktracev+0x35) [0x8086055]
1: akonadiserver() [0x8086516]
2: [0xb772e400]
3: [0xb772e416]
4: /lib/libc.so.6(gsignal+0x51) [0xb6e9f941]
5: /lib/libc.so.6(abort+0x182) [0xb6ea2e42]
6: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x8c) [0xb74d62dc]
7: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0xc4) [0x8087574]
8: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x8e) [0xb757168e]
9: /usr/lib/libQtCore.so.4(+0x103425) [0xb7581425]
10: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x3d) [0xb758295d]
11: akonadiserver(_ZN6QDebugD1Ev+0x43) [0x8081b73]
12: akonadiserver(_ZN13DbConfigMysql19startInternalServerEv+0x1c27) [0x810c177]
13: akonadiserver(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0xe3) [0x8087a23]
14: akonadiserver(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xca) [0x8088b6a]
15: akonadiserver(_ZN7Akonadi13AkonadiServer8instanceEv+0x48) [0x808a1d8]
16: akonadiserver(main+0x364) [0x8080fb4]
17: /lib/libc.so.6(__libc_start_main+0xe7) [0xb6e8bce7]
18: akonadiserver() [0x8080b81]
]
"
ProcessControl: Application 'akonadiserver' returned with exit code 255 (Unknown error)
search paths:  ("/home/patches/bin", "/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/usr/games", "/usr/sbin", "/usr/local/sbin", "/usr/local/libexec", "/usr/libexec", "/opt/mysql/libexec", "/opt/local/lib/mysql5/bin", "/opt/mysql/sbin") 
Found mysql_install_db:  "/usr/bin/mysql_install_db" 
Found mysqlcheck:  "/usr/bin/mysqlcheck" 
Database process exited unexpectedly during initial connection!
executable: "/usr/sbin/mysqld-akonadi"
arguments: ("--defaults-file=/home/patches/.local/share/akonadi//mysql.conf", "--datadir=/home/patches/.local/share/akonadi/db_data/", "--socket=/home/patches/.local/share/akonadi/socket-pleistocene/mysql.socket")
stdout: ""
stderr: "Could not open required defaults file: /home/patches/.local/share/akonadi//mysql.conf
Fatal error in defaults handling. Program aborted
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld-akonadi: Can't find file: './mysql/plugin.frm' (errno: 13)
110209 16:41:12 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110209 16:41:12  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
"
exit code: 1
process error: "Unknown error"
"[
0: akonadiserver(_Z11akBacktracev+0x35) [0x8086055]
1: akonadiserver() [0x8086516]
2: [0xb77ae400]
3: [0xb77ae416]
4: /lib/libc.so.6(gsignal+0x51) [0xb6f1f941]
5: /lib/libc.so.6(abort+0x182) [0xb6f22e42]
6: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x8c) [0xb75562dc]
7: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0xc4) [0x8087574]
8: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x8e) [0xb75f168e]
9: /usr/lib/libQtCore.so.4(+0x103425) [0xb7601425]
10: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x3d) [0xb760295d]
11: akonadiserver(_ZN6QDebugD1Ev+0x43) [0x8081b73]
12: akonadiserver(_ZN13DbConfigMysql19startInternalServerEv+0x1c27) [0x810c177]
13: akonadiserver(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0xe3) [0x8087a23]
14: akonadiserver(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xca) [0x8088b6a]
15: akonadiserver(_ZN7Akonadi13AkonadiServer8instanceEv+0x48) [0x808a1d8]
16: akonadiserver(main+0x364) [0x8080fb4]
17: /lib/libc.so.6(__libc_start_main+0xe7) [0xb6f0bce7]
18: akonadiserver() [0x8080b81]
]
"
ProcessControl: Application 'akonadiserver' returned with exit code 255 (Unknown error)
search paths:  ("/home/patches/bin", "/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/usr/games", "/usr/sbin", "/usr/local/sbin", "/usr/local/libexec", "/usr/libexec", "/opt/mysql/libexec", "/opt/local/lib/mysql5/bin", "/opt/mysql/sbin") 
Found mysql_install_db:  "/usr/bin/mysql_install_db" 
Found mysqlcheck:  "/usr/bin/mysqlcheck" 
Database process exited unexpectedly during initial connection!
executable: "/usr/sbin/mysqld-akonadi"
arguments: ("--defaults-file=/home/patches/.local/share/akonadi//mysql.conf", "--datadir=/home/patches/.local/share/akonadi/db_data/", "--socket=/home/patches/.local/share/akonadi/socket-pleistocene/mysql.socket")
stdout: ""
stderr: "Could not open required defaults file: /home/patches/.local/share/akonadi//mysql.conf
Fatal error in defaults handling. Program aborted
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld-akonadi: Can't find file: './mysql/plugin.frm' (errno: 13)
110209 16:41:12 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110209 16:41:12  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
"
exit code: 1
process error: "Unknown error"
"[
0: akonadiserver(_Z11akBacktracev+0x35) [0x8086055]
1: akonadiserver() [0x8086516]
2: [0xb778b400]
3: [0xb778b416]
4: /lib/libc.so.6(gsignal+0x51) [0xb6efc941]
5: /lib/libc.so.6(abort+0x182) [0xb6effe42]
6: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x8c) [0xb75332dc]
7: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0xc4) [0x8087574]
8: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x8e) [0xb75ce68e]
9: /usr/lib/libQtCore.so.4(+0x103425) [0xb75de425]
10: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x3d) [0xb75df95d]
11: akonadiserver(_ZN6QDebugD1Ev+0x43) [0x8081b73]
12: akonadiserver(_ZN13DbConfigMysql19startInternalServerEv+0x1c27) [0x810c177]
13: akonadiserver(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0xe3) [0x8087a23]
14: akonadiserver(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xca) [0x8088b6a]
15: akonadiserver(_ZN7Akonadi13AkonadiServer8instanceEv+0x48) [0x808a1d8]
16: akonadiserver(main+0x364) [0x8080fb4]
17: /lib/libc.so.6(__libc_start_main+0xe7) [0xb6ee8ce7]
18: akonadiserver() [0x8080b81]
]
"
ProcessControl: Application 'akonadiserver' returned with exit code 255 (Unknown error)
search paths:  ("/home/patches/bin", "/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/usr/games", "/usr/sbin", "/usr/local/sbin", "/usr/local/libexec", "/usr/libexec", "/opt/mysql/libexec", "/opt/local/lib/mysql5/bin", "/opt/mysql/sbin") 
Found mysql_install_db:  "/usr/bin/mysql_install_db" 
Found mysqlcheck:  "/usr/bin/mysqlcheck" 
Database process exited unexpectedly during initial connection!
executable: "/usr/sbin/mysqld-akonadi"
arguments: ("--defaults-file=/home/patches/.local/share/akonadi//mysql.conf", "--datadir=/home/patches/.local/share/akonadi/db_data/", "--socket=/home/patches/.local/share/akonadi/socket-pleistocene/mysql.socket")
stdout: ""
stderr: "Could not open required defaults file: /home/patches/.local/share/akonadi//mysql.conf
Fatal error in defaults handling. Program aborted
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Warning] Can't create test file /home/patches/.local/share/akonadi/db_data/pleistocene.lower-test
110209 16:41:12 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld-akonadi: Can't find file: './mysql/plugin.frm' (errno: 13)
110209 16:41:12 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110209 16:41:12  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
"
exit code: 1
process error: "Unknown error"
"[
0: akonadiserver(_Z11akBacktracev+0x35) [0x8086055]
1: akonadiserver() [0x8086516]
2: [0xb784e400]
3: [0xb784e416]
4: /lib/libc.so.6(gsignal+0x51) [0xb6fbf941]
5: /lib/libc.so.6(abort+0x182) [0xb6fc2e42]
6: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x8c) [0xb75f62dc]
7: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0xc4) [0x8087574]
8: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x8e) [0xb769168e]
9: /usr/lib/libQtCore.so.4(+0x103425) [0xb76a1425]
10: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x3d) [0xb76a295d]
11: akonadiserver(_ZN6QDebugD1Ev+0x43) [0x8081b73]
12: akonadiserver(_ZN13DbConfigMysql19startInternalServerEv+0x1c27) [0x810c177]
13: akonadiserver(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0xe3) [0x8087a23]
14: akonadiserver(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xca) [0x8088b6a]
15: akonadiserver(_ZN7Akonadi13AkonadiServer8instanceEv+0x48) [0x808a1d8]
16: akonadiserver(main+0x364) [0x8080fb4]
17: /lib/libc.so.6(__libc_start_main+0xe7) [0xb6fabce7]
18: akonadiserver() [0x8080b81]
]
"
ProcessControl: Application 'akonadiserver' returned with exit code 255 (Unknown error)
"akonadiserver" crashed too often and will not be restarted! 

I tried moving the ~/.local/share/akonadi folder and running it fresh, and I also tried starting Akonadi from a brand new user, all to no avail.

Requested by @djeikyb:

patches@pleistocene:~$ ls -ld ~/.local
drwxrwx--- 3 patches patches 4096 2011-02-07 03:15 /home/patches/.local


patches@pleistocene:~$ mysql_upgrade 
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' 
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect
FATAL ERROR: Upgrade failed

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

Best Answer

This seems to be a reoccurring problem for me on each install that I forget about. The above solution sort of solves the problem, but I wonder if there is another way. At this point, Ubuntu 11.10 Oneiric, all you need is

sudo aa-complain usr.sbin.mysqld-akonadi

to get Aknoadi up an running. But let's analyze the problem.

Apparmor is an adminstration security utility that places restrictions on programs. As Ubuntu is configured, the apparmor administrative utility enforces a security profile on /usr/sbin/mysqld-akonadi. This profile is in /etc/apparmor.d/usr.sbin.mysqld-akonadi", and it contains the following specification, which I've abbreviated here for the particular situation:

profile /usr/sbin/mysqld  {
    ## [stuff snipped]
    @{HOME}/.local/share/akonadi/** rwk,
}

I'm not sure, but I believe that "r" means "read", "w" means "write", and "k" means "mknod". This is saying that mysqld is allowed to create files and directories anywhere under the user's aknoadi directory.

Where/usr/sbin/mysqld-akonadi is failing according to the /var/log/kern.log is :

Apr 11 14:14:42 adiron kernel: [572346.502653] type=1400 audit(1334168082.226:675): apparmor="ALLOWED" operation="mknod" parent=31088 profile="/usr/sbin/mysqld-akonadi///usr/sbin/mysqld" name="/home/xxxxxx/.local/share/akonadi/db_data/adiron.lower-test" pid=31090 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000

It is saying that it is failing exactly on the "mknod" call. Strange, since I think it's configured for it.

However, "man apparmor" contains the following lines:

"A confined process can not call mknod(2) to create character or block devices."

This restriction seems to be in place regardless of the specification in the specific profile. A "confined" process is one that is in "enforce" mode. Issuing the aforementioned "aa-complain" command "unconfines" the process and then it is allowed to create the sockets, only complaining about it, along with everything else it is allowed to do, increasing your logs.

It is unclear whether with this seemingly uncircumventable restriction of using "mknod" in creating the mysql sockets can be configured away on the akonadi side. In any case, those seem only to be "Warnings" in the Akonadi log, and it seems that the real Errors are from things like :

Apr 11 13:00:10 adiron kernel: [567875.200843] type=1400 audit(1334163610.926:57): apparmor="DENIED" operation="open" parent=15318 profile="/usr/sbin/mysqld-akonadi///usr/sbin/mysqld" name="/home/xxxxx/.local/share/akonadi/db_data/ibdata1" pid=15320 comm="mysqld" requested_mask="rw" denied_mask="rw" fsuid=1000 ouid=1000
Apr 11 13:00:11 adiron kernel: [567875.355533] type=1400 audit(1334163611.078:58): apparmor="DENIED" operation="open" parent=15327 profile="/usr/sbin/mysqld-akonadi///usr/sbin/mysqld" name="//home/xxxxx/.local/share/akonadi/mysql.conf" pid=15329 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

of which Apparmor seems to be configured to allow. I'm at a loss on this one. However, switching the security OFF into complain mode makes it work. I guess you could just remove usr.sbin.mysql-akonadi from /etc/apparmor.d/ and that would be just as effective.

Related Question