Bug 476617 - postgresql16 fails to run after DB update from postgresql13 - errors from akonadictl start
Summary: postgresql16 fails to run after DB update from postgresql13 - errors from ako...
Status: RESOLVED WORKSFORME
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: 5.24.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-06 10:14 UTC by BingMyBong
Modified: 2023-11-06 20:43 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description BingMyBong 2023-11-06 10:14:07 UTC
Many years ago i migrated to using Postgresql 9.6 . I've since then updated the DB to postgresql10, 11, 12 until ver 13 which i 
have been using until now.  I  did try updating to ver 14 but it failed with  locale issues during the update and i couldn't get a resolution.  I've been without mail for a week now trying to get answers from support lists, unfortunately no-one has a solution

I just recently managed to get the database converted from postgresql13 to postgresql16 and the data was transferred to the new DB with no issues. 

I can't get Akonadi to load as it fails to start postgresql16, its failing with a message saying it needs postgesql9.6 as the DB was originally created using 9.6.  Help from Postgresql-novice mailing list (and Reinhard Max in opensuse buglist) identified that the postgresql-script is accessing /var/lib/pgsql/data and referencing the PG_VERSION file in that directory and it contains 9.6.  I can't see how this wasn't updated as each new version of Postgresql was installed.
 I can't even install Ver 9.6 to see if that cures the problem as its no longer in the opensuse repos.

Can anyone see a solution ? i was thinking of uninstalling every version of Postgresql and deleting 
/var/lib/pgsql/data directory manually if it doesn't disappear during the postgresql uninstall process.
I can then reinstall postgresql16 and hopefully it'll work again.

-------------- the section below lists: 1. my process to convert DB.  2. cli errors for ankonadictl start 3. errors in journal ----------

I update the DB manually via scripts with one file per action.
1. Backup
akonadictl stop
# copy for backup
cp -R $HOME/.local/share/akonadi/db_data $HOME/.local/share/akonadi/db_data_13
# rename so no db_data exists
mv $HOME/.local/share/akonadi/db_data $HOME/.local/share/akonadi/db_data_old

2. Create new DB
/usr/lib/postgresql16/bin/initdb --pgdata=$HOME/.local/share/akonadi/db_data 
--lc-collate=en_US.UTF-8 --locale=en_US.UTF-8 

3. Check upgrade 
/usr/lib/postgresql16/bin/pg_upgrade -b /usr/lib/postgresql13/bin -B /usr/lib/
postgresql16/bin  -d $HOME/.local/share/akonadi/db_data_13 -D $HOME/.local/
share/akonadi/db_data  --check

4. Do the upgrade if "3" worked okay 
/usr/lib/postgresql16/bin/pg_upgrade -b /usr/lib/postgresql13/bin -B /usr/lib/
postgresql16/bin -d $HOME/.local/share/akonadi/db_data_13 -D $HOME/.local/
share/akonadi/db_data

-------------- the section list errors from "akonadi start" ----------

~:> akonadictl start
org.kde.pim.akonadictl: Starting Akonadi Server...
org.kde.pim.akonadictl:    done.
~> Connecting to deprecated signal 
QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
org.kde.pim.akonadiserver: Starting up the Akonadi Server...
(QFileInfo(/usr/lib/postgresql/bin), QFileInfo(/usr/lib/postgresql/lib64))
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
org.kde.pim.akonadiserver: Invalid database object during database server 
startup
QProcess: Destroyed while process ("/usr/bin/pg_ctl") is still running.
org.kde.pim.akonadiserver: Shutting down AkonadiServer...
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited 
normally...

--------- this shows status using "systemctl status postgresql.service" ---

× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; 
preset: disabled)
     Active: failed (Result: exit-code) since Tue 2023-10-31 16:24:13 GMT; 
1min 31s ago
    Process: 5916 ExecStart=/usr/share/postgresql/postgresql-script start 
(code=exited, status=1/FAILURE)
        CPU: 8ms

Oct 31 16:24:13 Lian-Li systemd[1]: Starting PostgreSQL database server...
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Your database files were 
created by PostgreSQL version 9.6.
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Could not find executables 
for this version.
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Please install the 
PostgreSQL server package for version 9.6.
Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Control process 
exited, code=exited, status=1/FAILURE
Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Failed with result 
'exit-code'.
Oct 31 16:24:13 Lian-Li systemd[1]: Failed to start PostgreSQL database 
server.

---------- Errors from the journal using "journalctl -xeu postgresql.service"

Oct 31 16:24:13 Lian-Li systemd[1]: Starting PostgreSQL database server...
Subject: A start job for unit postgresql.service has begun execution
Defined-By: systemd
Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

A start job for unit postgresql.service has begun execution.
 
The job identifier is 2241.
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Your database files were 
created by PostgreSQL version 9.6.
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Could not find executables 
for this version.
Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Please install the 
PostgreSQL server package for version 9.6.
Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Control process 
exited, code=exited, status=1/FAILURE
Subject: Unit process exited
Defined-By: systemd
Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

An ExecStart= process belonging to unit postgresql.service has exited.
 
The process' exit code is 'exited' and its exit status is 1.
Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Failed with result 
'exit-code'.
Subject: Unit failed
Defined-By: systemd
Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

The unit postgresql.service has entered the 'failed' state with result 'exit-
code'.
Oct 31 16:24:13 Lian-Li systemd[1]: Failed to start PostgreSQL database 
server.
Subject: A start job for unit postgresql.service has failed
Defined-By: systemd
Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
A start job for unit postgresql.service has finished with a failure.

-----------------------

opensuse:tumbleweed:20231030
Qt: 5.15.11 KDE Frameworks: 5.111.0 - KDE Plasma:  5.27.9 - kwin 5.27.9
kmail2 5.24.2 (23.08.2) - akonadiserver 5.24.2 (23.08.2) - Kernel:  6.5.9-1-
default  - kernel-firmware-radeon  20231019
Comment 1 Christophe Marin 2023-11-06 11:40:02 UTC
(In reply to BingMyBong from comment #0)

> ---------- Errors from the journal using "journalctl -xeu postgresql.service"
> 
> Oct 31 16:24:13 Lian-Li systemd[1]: Starting PostgreSQL database server...
> Subject: A start job for unit postgresql.service has begun execution
> Defined-By: systemd
> Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 
> A start job for unit postgresql.service has begun execution.
>  
> The job identifier is 2241.
> Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Your database files were 
> created by PostgreSQL version 9.6.
> Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Could not find executables 
> for this version.
> Oct 31 16:24:13 Lian-Li postgresql-script[5916]:  Please install the 
> PostgreSQL server package for version 9.6.
> Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Control process 
> exited, code=exited, status=1/FAILURE
> Subject: Unit process exited
> Defined-By: systemd
> Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 
> An ExecStart= process belonging to unit postgresql.service has exited.
>  
> The process' exit code is 'exited' and its exit status is 1.
> Oct 31 16:24:13 Lian-Li systemd[1]: postgresql.service: Failed with result 
> 'exit-code'.
> Subject: Unit failed
> Defined-By: systemd
> Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

There's a small misunderstanding here. Akonadi doesn't use the system postgres but runs its own instance.
That's why the db lives in $HOME/.local/share/akonadi/db_data. Whatever lives in var/lib/pgsql is not your akonadi DB.

> QSqlDatabase: QPSQL driver not loaded

This looks more interesting. Is libQt5Sql5-postgresql installed on your system?
Comment 2 BingMyBong 2023-11-06 14:45:55 UTC
(In reply to Christophe Marin from comment #1)
> (In reply to BingMyBong from comment #0)
> 

> There's a small misunderstanding here. Akonadi doesn't use the system
> postgres but runs its own instance.
> That's why the db lives in $HOME/.local/share/akonadi/db_data. Whatever
> lives in var/lib/pgsql is not your akonadi DB.

I know very little about postgresql  so i have no idea why it started referencing that directory or file

> > QSqlDatabase: QPSQL driver not loaded
> 
> This looks more interesting. Is libQt5Sql5-postgresql installed on your
> system?
No, it wasn't.  I've now installed it and it works fine.  Would this file have been required by previous versions of postgresql?  If yes, i wonder how it got uninstalled.
Do you know if I can uninstall postgresql 11, 12, 13, 14 and 15 with zypper and not remove libQt5Sql5-postgresql?

Thanks a lot for having a look at my problem and giving me the solution.
Comment 3 Christophe Marin 2023-11-06 20:43:33 UTC
(In reply to BingMyBong from comment #2)
> 
> I know very little about postgresql  so i have no idea why it started
> referencing that directory or file

If you didn't enable it yourself, you can just prevent it from starting on your system (it won't affect akonadi):
sudo systemctl stop postgresql.service
sudo systemctl disable postgresql.service

> 
> > > QSqlDatabase: QPSQL driver not loaded
> > 
> > This looks more interesting. Is libQt5Sql5-postgresql installed on your
> > system?
> No, it wasn't.  I've now installed it and it works fine.  Would this file
> have been required by previous versions of postgresql?  If yes, i wonder how
> it got uninstalled.
> Do you know if I can uninstall postgresql 11, 12, 13, 14 and 15 with zypper
> and not remove libQt5Sql5-postgresql?

Yes, once your database is migrated and functional, you can uninstall old versions.