Bug 208763

Summary: Akonadi server with internal MySQL does not start for root
Product: [Frameworks and Libraries] Akonadi Reporter: Thorsten Staerk <dev>
Component: serverAssignee: Volker Krause <vkrause>
Status: RESOLVED FIXED    
Severity: normal CC: wstephenson
Priority: NOR    
Version: 4.3   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Thorsten Staerk 2009-09-28 12:32:09 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

Having installed and started mysql, I get the following error when starting korganizer:

Akonadi Server Self-Test Report
===============================

Test 1:  SUCCESS
--------

Database driver found.
Details: The QtSQL driver 'QMYSQL' is required by your current Akonadi server configuration and was found on your system.

File content of '/root/.config/akonadi/akonadiserverrc':
[%General]
Driver=QMYSQL
SizeThreshold=4096
ExternalPayload=false

[QMYSQL]
Name=akonadi
User=
Password=
Options="UNIX_SOCKET=/root/.local/share/akonadi/db_misc/mysql.socket"
ServerPath=/usr/sbin/mysqld
StartServer=true


Test 2:  SUCCESS
--------

MySQL server found.
Details: You currently have configured Akonadi to use the MySQL server '/usr/sbin/mysqld'.
Make sure you have the MySQL server installed, set the correct path and ensure you have the necessary read and execution rights on the server executable. The server executable is typically called 'mysqld', its locations varies depending on the distribution.

Test 3:  SUCCESS
--------

MySQL server is executable.
Details: MySQL server found: /usr/sbin/mysqld  Ver 5.0.67 for suse-linux-gnu on x86_64 (SUSE MySQL RPM)


Test 4:  SUCCESS
--------

No current MySQL error log found.
Details: The MySQL server did not report any errors during this startup into '/root/.local/share/akonadi/db_data/mysql.err'.

Test 5:  SUCCESS
--------

MySQL server default configuration found.
Details: The default configuration for the MySQL server was found and is readable at <a href='/usr/local/share/config/akonadi/mysql-global.conf'>/usr/local/share/config/akonadi/mysql-global.conf</a>.

File content of '/usr/local/share/config/akonadi/mysql-global.conf':
#
# Global Akonadi MySQL server settings,
# These settings can be adjusted using $HOME/.config/akonadi/mysql-local.conf
#
# Based on advice by Kris Köhntopp <kris@mysql.com>
#
[mysqld]
skip_grant_tables
skip_networking

# strict query parsing/interpretation
# TODO: make Akonadi work with those settings enabled
#sql_mode=strict_trans_tables,strict_all_tables,strict_error_for_division_by_zero,no_auto_create_user,no_auto_value_on_zero,no_engine_substitution,no_zero_date,no_zero_in_date,only_full_group_by,pipes_as_concat
#sql_mode=strict_trans_tables

# use InnoDB for transactions and better crash recovery
default_storage_engine=innodb
# case-insensitive table names, avoids trouble on windows
lower_case_table_names=1
character_set_server=latin1
collation_server=latin1_general_ci
table_cache=200
thread_cache_size=3
log_bin=mysql-bin
expire_logs_days=3
#sync_bin_log=0
# error log file name, relative to datadir
log_error=mysql.err
log_warnings=2
# log all queries, useful for debugging but generates an enormous amount of data
#log=mysql.full
# log queries slower than n seconds, log file name relative to datadir
log_slow_queries=mysql.slow
long_query_time=1
# log queries not using indices, debug only, disable for production use
log_queries_not_using_indexes=1
# maximum blob size
max_allowed_packet=32M
max_connections=256
# makes sense when having the same query multiple times
# makes no sense with prepared statements and/or transactions
query_cache_type=0
query_cache_size=0

innodb_file_per_table=1
innodb_log_buffer_size=1M
innodb_additional_mem_pool_size=1M
# messure database size and adjust
# SELECT sum(data_length) as bla, sum(index_length) as blub FROM information_schema.tables WHERE table_schema not in ("mysql", "information_schema");
innodb_buffer_pool_size=80M
# size of average write burst, keep Innob_log_waits small, keep Innodb_buffer_pool_wait_free small (see show global status like "inno%", show global variables)
innodb_log_file_size=64M
innodb_flush_log_at_trx_commit=2



Test 6:  SKIP
--------

MySQL server custom configuration not available.
Details: The custom configuration for the MySQL server was not found but is optional.

Test 7:  SUCCESS
--------

MySQL server configuration is usable.
Details: The MySQL server configuration was found at <a href='/root/.local/share/akonadi/mysql.conf'>/root/.local/share/akonadi/mysql.conf</a> and is readable.

File content of '/root/.local/share/akonadi/mysql.conf':
#
# Global Akonadi MySQL server settings,
# These settings can be adjusted using $HOME/.config/akonadi/mysql-local.conf
#
# Based on advice by Kris Köhntopp <kris@mysql.com>
#
[mysqld]
skip_grant_tables
skip_networking

# strict query parsing/interpretation
# TODO: make Akonadi work with those settings enabled
#sql_mode=strict_trans_tables,strict_all_tables,strict_error_for_division_by_zero,no_auto_create_user,no_auto_value_on_zero,no_engine_substitution,no_zero_date,no_zero_in_date,only_full_group_by,pipes_as_concat
#sql_mode=strict_trans_tables

# use InnoDB for transactions and better crash recovery
default_storage_engine=innodb
# case-insensitive table names, avoids trouble on windows
lower_case_table_names=1
character_set_server=latin1
collation_server=latin1_general_ci
table_cache=200
thread_cache_size=3
log_bin=mysql-bin
expire_logs_days=3
#sync_bin_log=0
# error log file name, relative to datadir
log_error=mysql.err
log_warnings=2
# log all queries, useful for debugging but generates an enormous amount of data
#log=mysql.full
# log queries slower than n seconds, log file name relative to datadir
log_slow_queries=mysql.slow
long_query_time=1
# log queries not using indices, debug only, disable for production use
log_queries_not_using_indexes=1
# maximum blob size
max_allowed_packet=32M
max_connections=256
# makes sense when having the same query multiple times
# makes no sense with prepared statements and/or transactions
query_cache_type=0
query_cache_size=0

innodb_file_per_table=1
innodb_log_buffer_size=1M
innodb_additional_mem_pool_size=1M
# messure database size and adjust
# SELECT sum(data_length) as bla, sum(index_length) as blub FROM information_schema.tables WHERE table_schema not in ("mysql", "information_schema");
innodb_buffer_pool_size=80M
# size of average write burst, keep Innob_log_waits small, keep Innodb_buffer_pool_wait_free small (see show global status like "inno%", show global variables)
innodb_log_file_size=64M
innodb_flush_log_at_trx_commit=2



Test 8:  SUCCESS
--------

akonadictl found and usable
Details: The program '/usr/local/bin/akonadictl' to control the Akonadi server was found and could be executed successfully.
Result:
Akonadi 1.2.61 (revision 1025184)


Test 9:  ERROR
--------

Akonadi control process not registered at D-Bus.
Details: The Akonadi control process is not registered at D-Bus which typically means it was not started or encountered a fatal error during startup.

Test 10:  ERROR
--------

Akonadi server process not registered at D-Bus.
Details: The Akonadi server process is not registered at D-Bus which typically means it was not started or encountered a fatal error during startup.

Test 11:  ERROR
--------

Nepomuk search service not registered at D-Bus.
Details: The Nepomuk search service is not registered at D-Bus which typically means it was not started or encountered a fatal error during startup.

Test 12:  SKIP
--------

Protocol version check not possible.
Details: Without a connection to the server it is not possible to check if the protocol version meets the requirements.

Test 13:  ERROR
--------

No resource agents found.
Details: No resource agents have been found, Akonadi is not usable without at least one. This usually means that no resource agents are installed or that there is a setup problem. The following paths have been searched: '/usr/local/share/akonadi/agents'. The XDG_DATA_DIRS environment variable is set to '/usr/local/share:/usr/share:/etc/opt/kde3/share:/opt/kde3/share', make sure this includes all paths where Akonadi agents are installed to.

Directory listing of '/usr/local/share/akonadi/agents':
birthdaysresource.desktop
contactsresource.desktop
distlistresource.desktop
icalresource.desktop
imapresource.desktop
kabcresource.desktop
kalarmresource.desktop
kalarmresource_active.desktop
kalarmresource_archived.desktop
kalarmresource_template.desktop
kcalresource.desktop
knutresource.desktop
kolabproxyresource.desktop
localbookmarksresource.desktop
maildirresource.desktop
maildispatcheragent.desktop
mboxresource.desktop
microblog.desktop
mtdummyresource.desktop
nepomuktagresource.desktop
nntpresource.desktop
notesresource.desktop
strigifeeder.desktop
vcarddirresource.desktop
vcardresource.desktop

Environment variable XDG_DATA_DIRS is set to '/usr/local/share:/usr/share:/etc/opt/kde3/share:/opt/kde3/share'

Test 14:  ERROR
--------

Current Akonadi server error log found.
Details: The Akonadi server did report error during startup into <a href='/root/.local/share/akonadi/akonadiserver.error'>/root/.local/share/akonadi/akonadiserver.error</a>.

File content of '/root/.local/share/akonadi/akonadiserver.error':
Database process exited unexpectedly during initial connection! 
executable: "/usr/sbin/mysqld" 
arguments: ("--defaults-file=/root/.local/share/akonadi//mysql.conf", "--datadir=/root/.local/share/akonadi/db_data/", "--socket=/root/.local/share/akonadi/db_misc/mysql.socket") 
stdout: "" 
stderr: "090928 12:35:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

090928 12:35:43 [ERROR] Aborting

090928 12:35:43 [Note] /usr/sbin/mysqld: Shutdown complete

" 
exit code: 1 
process error: "Unknown error" 
"[
0: akonadiserver(_Z11akBacktracev+0x32) [0x4141d2]
1: akonadiserver [0x414675]
2: /lib64/libc.so.6 [0x7ff898a136e0]
3: /lib64/libc.so.6(gsignal+0x35) [0x7ff898a13645]
4: /lib64/libc.so.6(abort+0x183) [0x7ff898a14c33]
5: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x85) [0x7ff89a93d885]
6: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0x10f) [0x415ff5]
7: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x81) [0x7ff89a9c9ab1]
8: /usr/lib/libQtCore.so.4 [0x7ff89a9d5eec]
9: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x68) [0x7ff89a9d6198]
10: akonadiserver(_ZN6QDebug6StreamD1Ev+0x2d) [0x40ff4d]
11: akonadiserver(_ZN6QDebugD1Ev+0xb7) [0x410039]
12: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0x2bf4) [0x7ff89adc6f1a]
13: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xac) [0x7ff89adc8e26]
14: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServer8instanceEv+0x33) [0x7ff89adcaad3]
15: akonadiserver(main+0x6c7) [0x40e813]
16: /lib64/libc.so.6(__libc_start_main+0xe6) [0x7ff8989ff586]
17: akonadiserver [0x40e089]
]
" 


Test 15:  ERROR
--------

Previous Akonadi server error log found.
Details: The Akonadi server did report error during its previous startup into <a href='/root/.local/share/akonadi/akonadiserver.error.old'>/root/.local/share/akonadi/akonadiserver.error.old</a>.

File content of '/root/.local/share/akonadi/akonadiserver.error.old':
Database process exited unexpectedly during initial connection! 
executable: "/usr/sbin/mysqld" 
arguments: ("--defaults-file=/root/.local/share/akonadi//mysql.conf", "--datadir=/root/.local/share/akonadi/db_data/", "--socket=/root/.local/share/akonadi/db_misc/mysql.socket") 
stdout: "" 
stderr: "090928 12:35:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

090928 12:35:43 [ERROR] Aborting

090928 12:35:43 [Note] /usr/sbin/mysqld: Shutdown complete

" 
exit code: 1 
process error: "Unknown error" 
"[
0: akonadiserver(_Z11akBacktracev+0x32) [0x4141d2]
1: akonadiserver [0x414675]
2: /lib64/libc.so.6 [0x7f73b7c876e0]
3: /lib64/libc.so.6(gsignal+0x35) [0x7f73b7c87645]
4: /lib64/libc.so.6(abort+0x183) [0x7f73b7c88c33]
5: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x85) [0x7f73b9bb1885]
6: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0x10f) [0x415ff5]
7: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x81) [0x7f73b9c3dab1]
8: /usr/lib/libQtCore.so.4 [0x7f73b9c49eec]
9: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x68) [0x7f73b9c4a198]
10: akonadiserver(_ZN6QDebug6StreamD1Ev+0x2d) [0x40ff4d]
11: akonadiserver(_ZN6QDebugD1Ev+0xb7) [0x410039]
12: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0x2bf4) [0x7f73ba03af1a]
13: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServerC1EP7QObject+0xac) [0x7f73ba03ce26]
14: /usr/local/lib64/libakonadiprivate.so.1(_ZN7Akonadi13AkonadiServer8instanceEv+0x33) [0x7f73ba03ead3]
15: akonadiserver(main+0x6c7) [0x40e813]
16: /lib64/libc.so.6(__libc_start_main+0xe6) [0x7f73b7c73586]
17: akonadiserver [0x40e089]
]
" 


Test 16:  SUCCESS
--------

No current Akonadi control error log found.
Details: The Akonadi control process did not report any errors during its current startup.

Test 17:  SUCCESS
--------

No previous Akonadi control error log found.
Details: The Akonadi control process did not report any errors during its previous startup.
Comment 1 Thorsten Staerk 2009-09-28 12:35:13 UTC
When trying to manually start mysql:
/usr/sbin/mysqld --defaults-file=/root/.local/share/akonadi//mysql.conf --datadir=/root/.local/share/akonadi/db_data/ --socket=/root/.local/share/akonadi/db_misc/mysql.socket


I get:
090928 12:39:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

090928 12:39:43 [ERROR] Aborting

090928 12:39:43 [Note] /usr/sbin/mysqld: Shutdown complete
Comment 2 Volker Krause 2009-09-28 13:09:16 UTC
Looks like a problem with running Akonadi (or rather MySQL) as root. Does it work with a normal user?
Comment 3 Thorsten Staerk 2010-01-15 10:52:37 UTC
Workaround is to use a central mysql daemon: http://techbase.kde.org/Projects/PIM/Akonadi#Can_Akonadi_use_a_normal_MySQL_server_running_on_my_system.3F
Comment 4 Will Stephenson 2010-02-08 12:06:07 UTC
I just had a user report this as well.  Mysql refuses to start with the out of the box config when kdepim apps are run as root.  It works fine as a regular user.  

If it's not worth fixing the config to allow running as root (although this case might be relevant on mobile devices where everything runs as root) then at least the framework should check for root and fail gracefully instead of letting mysql abort.
Comment 5 Will Stephenson 2010-03-24 10:59:08 UTC
I've added a self-test to clearly warn the user why Akonadi+MySQL won't start as root.  
I can see that it should be possible to run as root if you really want to, which can be done with a local MySQL by adding "user=root" to mysql-local.conf, but this is so corner I think it's sufficient to warn the user that it's a bad idea.

svn rev 1106949 is the commit.