Bug 286826 - After system crash, postgresql akonadi server doesn't start due to lock file
Summary: After system crash, postgresql akonadi server doesn't start due to lock file
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: 4.7
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-17 08:02 UTC by Benjamin M
Modified: 2014-05-06 14:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 1.12.2
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin M 2011-11-17 08:02:11 UTC
Version:           4.7 (using KDE 4.7.3) 
OS:                Linux

Sometimes my system crashes, some times when my battery dies or when my laptop doesn't wake up from sleep/hibernation. Whenever I restart after a proper shutdown, the akonadi server doesn't start - because the postgresql lock file is still in place. 

Reproducible: Always

Steps to Reproduce:
Use an internatl postgresql server backend for akonadi. After a forced shutdown or crash, boot. Akonadi won't start. Try starting it manually, same results. 

Actual Results:  
/home/[user]/.local/share/akonadi/db_data/postmaster.log will tell you the reason: 

2011-11-17 07:14:48 GMT   FATAL:  lock file "postmaster.pid" already exists
2011-11-17 07:14:48 GMT   HINT:  Is another postmaster (PID 4637) running in data directory "/home/alvanx/.local/share/akonadi/db_data"?
2011-11-17 08:14:55 CET   FATAL:  lock file "/home/alvanx/.local/share/akonadi/socket-alvanx/.s.PGSQL.5432.lock" already exists
2011-11-17 08:14:55 CET   HINT:  Is another postmaster (PID 4655) using socket file "/home/alvanx/.local/share/akonadi/socket-alvanx/.s.PGSQL.5432"?

Deleting the latter lock file solved the problem for me. (The lock file "postmaster.pid" did not seem to be relevant for this particular problem.)

Expected Results:  
Akonadi or the server or whatever should somehow understand what happened. Maybe it needs another way to doublecheck if the database server is already running? I am really a noob at this, but I do know a bug when I see one, even if it may only be a usability bug. 

At the very least, the akonadi backtrace should offer sufficient information right upfront to allow the user to track down the problem right away so he can check for himself. 

Here is the error log file: 

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

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

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

File content of '/home/alvanx/.config/akonadi/akonadiserverrc':
[%General]
Driver=QPSQL

[QPSQL]
StartServer=true
Name=akonadi
Host=/home/alvanx/.local/share/akonadi/socket-alvanx
Options=
ServerPath=/usr/bin/pg_ctl
InitDbPath=/usr/bin/initdb
User=
Password=
Port=5432

[QMYSQL]
StartServer=true
ServerPath=/usr/sbin/mysqld
Name=akonadi
Host=
User=
Password=
Options="UNIX_SOCKET=/home/alvanx/.local/share/akonadi/socket-alvanx/mysql.socket"

[Debug]
Tracer=null


Test 2:  ERROR
--------

Cannot connect to PostgreSQL server.
Details: konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt
	L�uft der Server lokal und akzeptiert er Verbindungen
	auf dem Unix-Domain-Socket �/home/alvanx/.local/share/akonadi/socket-alvanx/.s.PGSQL.5432�?
QPSQL: Verbindungsaufbau nicht m�glich

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

akonadictl found and usable
Details: The program '/usr/bin/akonadictl' to control the Akonadi server was found and could be executed successfully.
Result:
Akonadi 1.6.0


Test 4:  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 5:  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 6:  SUCCESS
--------

Nepomuk search service registered at D-Bus.
Details: The Nepomuk search service is registered at D-Bus which typically indicates it is operational.

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

Nepomuk search service uses an appropriate backend. 
Details: The Nepomuk search service uses one of the recommended backends.

Test 8:  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 9:  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/share/akonadi/agents'. The XDG_DATA_DIRS environment variable is set to '/usr/local/share:/usr/share:/etc/opt/kde3/share:/opt/gnome/share:/opt/kde3/share'; make sure this includes all paths where Akonadi agents are installed.

Directory listing of '/usr/share/akonadi/agents':
akonotesresource.desktop
birthdaysresource.desktop
calendarsearchagent.desktop
contactsresource.desktop
davgroupwareresource.desktop
icalresource.desktop
imapresource.desktop
invitationsagent.desktop
kabcresource.desktop
kcalresource.desktop
kdeaccountsresource.desktop
kolabproxyresource.desktop
localbookmarksresource.desktop
maildirresource.desktop
maildispatcheragent.desktop
mboxresource.desktop
microblog.desktop
mixedmaildirresource.desktop
mtdummyresource.desktop
nepomukcalendarfeeder.desktop
nepomukcontactfeeder.desktop
nepomukemailfeeder.desktop
nepomuktagresource.desktop
nntpresource.desktop
notesresource.desktop
openxchangeresource.desktop
pop3resource.desktop
vcarddirresource.desktop
vcardresource.desktop

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

Test 10:  SUCCESS
--------

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

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

Previous Akonadi server error log found.
Details: The Akonadi server reported errors during its previous startup. The log can be found in <a href='/home/alvanx/.local/share/akonadi/akonadiserver.error.old'>/home/alvanx/.local/share/akonadi/akonadiserver.error.old</a>.

File content of '/home/alvanx/.local/share/akonadi/akonadiserver.error.old':
Database process exited unexpectedly during initial connection! 
executable: "/usr/bin/pg_ctl" 
arguments: ("-w", "-t10", "start", "-D/home/alvanx/.local/share/akonadi/db_data") 
stdout: "warte auf Start des Servers............." 
stderr: "pg_ctl: konnte Server nicht starten
Prüfen Sie die Logausgabe.
" 
exit code: 1 
process error: "Process operation timed out" 
"[
0: akonadiserver(_Z11akBacktracev+0x35) [0x808c9c5]
1: akonadiserver() [0x808cdcc]
2: [0xffffe400]
3: [0xffffe424]
4: /lib/libc.so.6(gsignal+0x4f) [0xb6ed38df]
5: /lib/libc.so.6(abort+0x180) [0xb6ed5220]
6: /usr/lib/libQtCore.so.4(_Z17qt_message_output9QtMsgTypePKc+0x8a) [0xb7593cda]
7: akonadiserver(_ZN15FileDebugStream9writeDataEPKcx+0xd8) [0x808ef28]
8: /usr/lib/libQtCore.so.4(_ZN9QIODevice5writeEPKcx+0x9b) [0xb762e5bb]
9: /usr/lib/libQtCore.so.4(+0x100dcf) [0xb7637dcf]
10: /usr/lib/libQtCore.so.4(_ZN11QTextStreamD1Ev+0x3e) [0xb7641c3e]
11: akonadiserver(_ZN18DbConfigPostgresql19startInternalServerEv+0x16f8) [0x81200a8]
12: akonadiserver(_ZN7Akonadi13AkonadiServer20startDatabaseProcessEv+0xef) [0x808f34f]
13: akonadiserver() [0x809221a]
14: akonadiserver(_ZN7Akonadi13AkonadiServer8instanceEv+0x2b) [0x809396b]
15: akonadiserver(main+0x219) [0x80875b9]
16: /lib/libc.so.6(__libc_start_main+0xfe) [0xb6ebec2e]
17: akonadiserver() [0x80872d1]
]
" 


Test 12:  SUCCESS
--------

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

Test 13:  SUCCESS
--------

No previous Akonadi control error log found.
Details: The Akonadi control process did not report any errors during its previous startup.
Comment 1 Benjamin M 2011-11-17 08:04:00 UTC
Correction to 2nd sentence: "Whenever I restart after a proper
shutdown, ..." should be "Whenever I restart after an improper
shutdown, ...".
Comment 2 Daniel Vrátil 2014-05-06 14:42:11 UTC
Git commit f217d9e96dc8de88916e8ca0b93dd9a7500bbbc3 by Dan Vrátil.
Committed on 06/05/2014 at 14:38.
Pushed by dvratil into branch '1.12'.

Fix PostgreSQL start when postmaster.pid is not removed after non-clean shutdown

When PostgreSQL is not terminated nicely, a pidfile is left behind in db_data,
which will prevent pg_ctl from starting a new PostgreSQL server.

We check for postmaster.pid file and verify that postgres server with PID
specified in the pidfile is not running anymore, then delete the pidfile to
allow pg_ctl to start a new server. If the postgres server is still running
(possibly after Akonadi server crash), we try to connect to it right away.
FIXED-IN: 1.12.2

M  +37   -0    server/src/storage/dbconfigpostgresql.cpp

http://commits.kde.org/akonadi/f217d9e96dc8de88916e8ca0b93dd9a7500bbbc3