Posts Upgrading Postgres with Postgis after a Fedora upgrade
Post
Cancel

Upgrading Postgres with Postgis after a Fedora upgrade

Fedora upgrades

I will keep this short and simple, a tale of my journey with Fedora will come another time. Fedora upgrades work mostly perfectly. But after several upgrades over the past five years, I started collecting, along my dotfiles, a small checklist of things that both might have messed up after an upgrade and things that most definitely will get broken. Of course, CUDA has a wiki of it’s own.

Postgres is the kind of thing that has been broken on my system for some time after an upgrade, with Postgis being it’s only culprit. No biggie, I tend to use docker anyway.

So, today, after upgrading from Fedora 35 to 37, I checked, and indeed the service was not coming up.

Postgres upgrade

My wiki said to run:

1
# systemctl status postgresql.service

Which output:

1
2
3
4
5
6
7
8
9
10
11
12
13
× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Fri 2022-12-16 13:44:29 -03; 51min ago
    Process: 168833 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=1/FAILURE)
        CPU: 10ms

Dec 16 13:44:29 <hostname> systemd[1]: Starting postgresql.service - PostgreSQL database server...
Dec 16 13:44:29 <hostname> postgresql-check-db-dir[168833]: An old version of the database format was found.
Dec 16 13:44:29 <hostname> postgresql-check-db-dir[168833]: Use 'postgresql-setup --upgrade' to upgrade to version '14'
Dec 16 13:44:29 <hostname> postgresql-check-db-dir[168833]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
Dec 16 13:44:29 <hostname> systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Dec 16 13:44:29 <hostname> systemd[1]: postgresql.service: Failed with result 'exit-code'.
Dec 16 13:44:29 <hostname> systemd[1]: Failed to start postgresql.service - PostgreSQL database server.

Ok, let’s try that:

1
2
3
4
5
# postgresql-setup --upgrade
 * Upgrading database.
ERROR: pg_upgrade tool failed
ERROR: Upgrade failed.
 * See /var/lib/pgsql/upgrade_postgresql.log for details.

Let’s see the logs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# cat /var/lib/pgsql/upgrade_postgresql.log
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Creating dump of global objects                             ok
Creating dump of database schemas
  db1
  db2
  ...
  postgres

*failure*

Consult the last few lines of "pg_upgrade_dump_16581.log" for
the probable cause of the failure.
Failure, exiting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# cat /var/lib/pgsql/pg_upgrade_dump_16581.log
command: "/usr/bin/pg_dump" --host /var/lib/pgsql --port 5432 --username postgres --schema-only --quote-all-identifiers --binary-upgrade --format=custom  --file="pg_upgrade_dump_16581.custom" 'dbname=postgres' >> "pg_upgrade_dump_16581.log" 2>&1
pg_dump: error: query failed: ERROR:  could not access file "$libdir/postgis-3": No such file or directory
pg_dump: error: query was: SELECT
proretset,
prosrc,
probin,
provolatile,
proisstrict,
prosecdef,
lanname,
proconfig,
procost,
prorows,
pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,
pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,
pg_catalog.pg_get_function_result(p.oid) AS funcresult,
proleakproof,
array_to_string(protrftypes, ' ') AS protrftypes,
proparallel,
prokind,
prosupport,
NULL AS prosqlbody
FROM pg_catalog.pg_proc p, pg_catalog.pg_language l
WHERE p.oid = '63708'::pg_catalog.oid AND l.oid = p.prolang

Postgis fix

So, clearly, the failure is due to postgis. On this bugzilla ticket from a couple years ago, I found a potential solution: to install postgis-upgrade. I don’t know where this is documented, but after running:

1
2
3
4
# dns install postgis-upgrade
# postgresql-setup --upgrade
 * Upgrading database.
 * Upgraded OK.

The problem is solved.

This post is licensed under MIT by the author.