akonadi
Contents
About
Upgrade Postgres
Trouble Shooting
collation version mismatch
If on akonadictl restart you receive the following error
1 WARNING: database "postgres" has a collation version mismatch
2 DETAIL: The database was created using collation version 2.36, but the operating system provides version 2.40.
3 TIP: Rebuild all objects in this database that use the default collation and run ALTER DATABASE postgres REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
The postgresql socket resides in
~/.local/share/akonadi/socket-$HOSTNAME-default
Fix refresh collation version
1 % psql -h ~/.local/share/akonadi/socket-$HOSTNAME-default -d akonadi
2 psql (18.1 (Debian 18.1-1))
3 Geben Sie »help« für Hilfe ein.
4
5 akonadi=# ALTER DATABASE template1 REFRESH COLLATION VERSION;
6 NOTICE: changing version from 2.36 to 2.41
7 ALTER DATABASE
8 akonadi=# ALTER DATABASE postgres REFRESH COLLATION VERSION;
9 NOTICE: changing version from 2.40 to 2.41
10 ALTER DATABASE
11 akonadi=# ALTER DATABASE akonadi REFRESH COLLATION VERSION;
12 NOTICE: changing version from 2.41 to 2.42
13 ALTER DATABASE
14 akonadi=#
15 akonadi=# \q
16 %
postgresql.conf contains errors
If you receive an error on
akonadictl start
1 akonadictl start
2 org.kde.pim.akonadictl: Starting Akonadi Server...
3 org.kde.pim.akonadictl: done.
4 Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
5 org.kde.pim.akonadiserver: Starting up the Akonadi Server...
6 QList(QFileInfo(/usr/lib/postgresql/17), QFileInfo(/usr/lib/postgresql/18))
7 org.kde.pim.akonadiserver: Database process exited unexpectedly during initial connection!
8 org.kde.pim.akonadiserver: executable: "/usr/lib/postgresql/17/bin/pg_ctl"
9 org.kde.pim.akonadiserver: arguments: QList("start", "-w", "--timeout=10", "--pgdata=/home/tobias/.local/share/akonadi/db_data", "-o \"-k/run/user/1000/akonadi\" -h ''")
10 org.kde.pim.akonadiserver: stdout: "warte auf Start des Servers....2025-11-20 08:21:06.007 GMT [1413499] LOG: unbekannter Konfigurationsparameter \xC2\xBB""autovacuum_worker_slots\xC2\xAB in Datei \xC2\xBB/home/tobias/.local/share/akonadi/db_data/postgresql.conf\xC2\xAB Zeile 683\n2025-11-20 08:21:06.007 GMT [1413499] FATAL: Konfigurationsdatei \xC2\xBB/home/tobias/.local/share/akonadi/db_data/postgresql.conf\xC2\xAB enth\xC3\xA4lt Fehler\n Warten beendet\n"
11 org.kde.pim.akonadiserver: stderr: "pg_ctl: konnte Server nicht starten\nPr\xC3\xBC""fen Sie die Logausgabe.\n"
12 org.kde.pim.akonadiserver: exit code: 1
13 org.kde.pim.akonadiserver: process error: "Unbekannter Fehler"
14 org.kde.pim.akonadiserver: Failed to remove runtime connection config file
15 org.kde.pim.akonadiserver: Shutting down AkonadiServer...
16 org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited normally...
Akonadi is in this case using an old executable. This config resides in
$XDG_CONFIG_HOME/akonadi,
which corresponds to
~/.config/akonadi.
Adjust the config to the new postgresql version
~/.config/akonadi/akonadiserverrc
1 [Debug]
2 Tracer=null
3
4 [%General]
5 %23Driver=QMYSQL
6 Driver=QPSQL
7
8 [QMYSQL]
9 Host=
10 Name=akonadi
11 Options="UNIX_SOCKET=/run/user/1000/akonadi/mysql.socket"
12 ServerPath=/usr/sbin/mysqld
13 StartServer=true
14
15 [QPSQL]
16 Host=/run/user/1000/akonadi
17 InitDbPath=/usr/lib/postgresql/18/bin/initdb
18 Name=akonadi
19 Options=
20 PgData=/home/tobias/.local/share/akonadi/db_data
21 ServerPath=/usr/lib/postgresql/18/bin/pg_ctl
22 StartServer=true
And restart akonadi
1 akonadictl start
Xapian error DatabaseCorruptError
If you cannot search your email, contacts, … there is probably a problem with the xapian indexes, which are located in the sub-directories of
~/.local/share/akonadi/search_db
Verify
To verify open akonadiconsole in a shell (to get the log information written to STDOUT). Chose tab "Item Search" and select the store in my case "Email" An error is risen and on clicking "OK" akonadiconsole terminates with SIGABRT (6).
DatabaseCorruptError: Expected block 512 to be level 2, not 0
The info logged to in the shell states
postlist.glass seems to be 32TiB in size.
There may be something wrong.
1 % ls -lh ~/.local/share/akonadi/search_db/email
2 insgesamt 534M
3 -rw-r--r-- 1 tobias tobias 12M 22. Mär 2024 docdata.glass
4 -rw-r--r-- 1 tobias tobias 0 25. Jan 10:26 flintlock
5 -rw-r--r-- 1 tobias tobias 140 11. Mär 2024 iamglass
6 -rw-r--r-- 1 tobias tobias 32T 11. Mär 2024 postlist.glass
7 -rw-r--r-- 1 tobias tobias 257M 24. Mär 2024 termlist.glass
Fix
First make sure you have xapian-check available.
On Debian install
1 aptitude install xapian-tools
Stop akonadi
1 akonadictl stop
Create a backup
1 cp -pr ~/.local/share/akonadi/search_db/email{,_bak}
Analyze the database (no change)
1 % xapian-check ~/.local/share/akonadi/search_db/email
2 Database couldn't be opened for reading: DatabaseCorruptError: Expected block 512 to be level 2, not 0
3 Continuing check anyway
4 docdata:
5 blocksize=8K items=69147 firstunused=1388 revision=16615 levels=2 root=28
6 B-tree checked okay
7 docdata table structure checked OK
8
9 termlist:
10 blocksize=8K items=138456 firstunused=31862 revision=16615 levels=2 root=21246
11 xapian-check: DatabaseError: Block 2208: Used block also in freelist
Fix a database with xapian-check - didn't work out.
1 % xapian-check ~/.local/share/akonadi/search_db/email F
2 Database couldn't be opened for reading: DatabaseCorruptError: Expected block 512 to be level 2, not 0
3 Continuing check anyway
4 docdata:
5 B-tree checked okay
6 docdata table structure checked OK
7
8 termlist:
9 xapian-check: DatabaseError: Block 2208: Used block also in freelist
I found no way to recover the broken file. The only solution I found was
- stop akonadi,
1 akonadictl stop - delete the entire directory,
1 rm -r ~/.local/share/akonadi/search_db/email - start akonadi
1 akonadictl start - fix the permissions
- re-index the email
- Email is generally indexed, when the item is retrieved, but touching everything is odd.
- Automatic indexing
- Open the folder-properties of your inbox
- Select the right most tab "Maintenance"
- There should be a button "Reindex Folder"
- If yes:
Open akonadiconsole
- Press the button
Monitor the progress in akonadiconsole
- Wait patiently (takes a while)
- If not:
Open akonadiconsole
- Enable local mailbox synchronization in:
Properties > Configure KMail …
Accounts > Receiving > $YOUR_ACCOUNT > General
- Check if the button is available now
- If yes:
Could not create collection trash, resourceid
Kmail/Kontact crashes
Open akonadiconsole
Tab DB-Browser:
Select 'resourcetable' and match the resourceid (9) -> akonadi_maildir_resource_0
Select 'collectiontable ', sort by resourceid -> trash
"Local folders" are located in ~/.local/share/local-mail
FIX
There are probably ways to fix the maildir, but for trash it's probably okay to move it away (and later discard it).