Bug 512859

Summary: Updating mariadb to 12.1 causes akonadi to not start
Product: [Frameworks and Libraries] Akonadi Reporter: Anders Lund <anders>
Component: generalAssignee: kdepim bugs <pim-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: arojas, carl, tl
Priority: NOR    
Version First Reported In: 6.5.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.6.0
Sentry Crash Report:
Attachments: Patch for the "foreign key" SQL syntax error

Description Anders Lund 2025-12-02 09:26:22 UTC
SUMMARY

Upgrading mariadb to 12.1.2 causes akonadi to crash during startup, due to mariadb not understanding sql query. This is a compatibility issue, so I am not sure who to blame.

STEPS TO REPRODUCE
1. update mariadb to 12.1.2 (on archlinux, pacman -Suy will normally cause this if 12.1.2 is the current mariadb version)
2. run kmail (or possibly any other akonadi client)

OBSERVED RESULT
Kmail fails to start


EXPECTED RESULT
Kmail working

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: archlinux, up to date
KDE Plasma Version: 6.5.3
KDE Frameworks Version: 6.20.0
Qt Version: 6.10.1

ADDITIONAL INFORMATION
mariadb 12.0 works, 12.1.2 does not
Comment 1 Allen Winter 2025-12-02 12:34:04 UTC
you gave no details (like try running akonadiserver from a command line and post anything strange) but

check  https://userbase.kde.org/Akonadi#If_Akonadi_Reports_Broken_or_Non-operational to start with
Comment 2 Anders Lund 2025-12-02 14:04:51 UTC
(In reply to Allen Winter from comment #1)
> you gave no details (like try running akonadiserver from a command line and
> post anything strange) but
> 
> check 
> https://userbase.kde.org/Akonadi#If_Akonadi_Reports_Broken_or_Non-
> operational to start with

I have had a working installation for years. Only thing I could find that caused this problem was the mariadb update. It's not like updating archlinux deletes any dependencies, or otherwise changes things.
Comment 3 Tobias Leupold 2025-12-02 18:25:39 UTC
I'm pretty sure I ran into exactly this issue. I just set up a new notebook with Artix Linux and MariaDB 12.1.2. I now wanted to setup KMail, but it's not functional due to Akonadi not being able to initialize the database and thus not running.

akonadictl start gives more insight, seems this is due to a syntax error:

akonadictl start


org.kde.pim.akonadictl: Starting Akonadi Server...
org.kde.pim.akonadictl:    done.
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
qt.qpa.services: Failed to register with host portal QDBusError("org.freedesktop.portal.Error.Failed", "Could not register app ID: App info not found for 'org.kde.akonadi_control'")
org.kde.pim.akonadiserver: Starting up the Akonadi Server...
/usr/bin/mysqlcheck: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-check' instead
akonadi.collectionattributetable                   OK
akonadi.collectionmimetyperelation                 OK
akonadi.collectionpimitemrelation                  OK
akonadi.collectiontable                            OK
akonadi.flagtable                                  OK
akonadi.mimetypetable                              OK
akonadi.parttable                                  OK
akonadi.parttypetable                              OK
akonadi.pimitemflagrelation                        OK
akonadi.pimitemtable                               OK
akonadi.pimitemtagrelation                         OK
akonadi.resourcetable                              OK
akonadi.schemaversiontable                         OK
akonadi.tagattributetable                          OK
akonadi.tagremoteidresourcerelationtable           OK
akonadi.tagtable                                   OK
akonadi.tagtypetable                               OK
/usr/bin/mysql_upgrade: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-upgrade' instead
This installation of MariaDB is already upgraded to 12.1.2-MariaDB.
There is no need to run mariadb-upgrade again.
You can use --force if you still want to run mariadb-upgrade
org.kde.pim.akonadiserver: Running DB initializer
org.kde.pim.akonadiserver: DB initializer done
org.kde.pim.akonadiserver: Updating index failed:  
Sql error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2' at line 1 QMYSQL: Die Abfrage konnte nicht ausgeführt werden
Query: ALTER TABLE PimItemTable DROP FOREIGN KEY 2
org.kde.pim.akonadiserver: ""
org.kde.pim.akonadiserver: Unable to initialize database.
org.kde.pim.akonadiserver: Shutting down AkonadiServer...
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited normally...

Seems like MariaDB doesn't like "ALTER TABLE PimItemTable DROP FOREIGN KEY 2" anymore?
Comment 4 Tobias Leupold 2025-12-02 18:31:26 UTC
Additional note: I also have three other Artix machines running, all with MariaDB 12.1.2. No problems on any of them. Apparently, this only happens when Akonadi tries to setup a new database.
Comment 5 Tobias Leupold 2025-12-02 21:05:20 UTC
Another addition: If I downgrade to MariaDB 12.0.2, Akonadi starts normally, i.e. the database is initialized correctly. As soon as I upgrade to 12.1.2, Akonadi fails to start. Don't ask me why my other Atrix machines using this version work nevertheless though …
Comment 6 Tobias Leupold 2025-12-03 10:22:04 UTC
This seems to be the change causing this: https://jira.mariadb.org/browse/MDEV-28933
Comment 7 Tobias Leupold 2025-12-03 11:47:19 UTC
Created attachment 187320 [details]
Patch for the "foreign key" SQL syntax error

I'm far from being a MariaDB or Akonadi professional, but it seems that all we have to do is to quote the foreign key identifier. At least, a local build with this small patch works fine using MariaDB 12.1.2.
Comment 8 Antonio Rojas 2025-12-04 08:33:39 UTC
(In reply to Tobias Leupold from comment #7)
> Created attachment 187320 [details]
> Patch for the "foreign key" SQL syntax error
> 
> I'm far from being a MariaDB or Akonadi professional, but it seems that all
> we have to do is to quote the foreign key identifier. At least, a local
> build with this small patch works fine using MariaDB 12.1.2.

You may want to open a merge request, given that the maintainer decided to unsubscribe for some reason.
Comment 9 Tobias Leupold 2025-12-04 08:55:21 UTC
Huh?! Well, okay, I'll file a MR. Thanks for the hint, that at least explains that nobody commented on the patch yet.
Comment 10 Tobias Leupold 2025-12-04 09:18:13 UTC
Here we are: https://invent.kde.org/pim/akonadi/-/merge_requests/310