Discourse_docker default templates and postgres version are out of sync

Hello all, as I look into adding the “pglogical” extension to our Postgres DB, I am noticing some discrepancies between the version of postgres installed and the version cited by the postgres template and configuration files.

The version of postgres currently installed is v16.2 (released Feb. 2024), but the config files all are still associated with v13, e.g.,

root@ip-172-31-62-223-app:/var/www/discourse# sudo -u postgres psql discourse
psql (16.2 (Debian 16.2-1.pgdg110+2), server 13.14 (Debian 13.14-1.pgdg110+2))
Type "help" for help.

discourse=# SHOW config_file;
               config_file               
-----------------------------------------
 /etc/postgresql/13/main/postgresql.conf
(1 row)

or the postgres.template file, which only goes up to v13.

This is only an issue for me right now because the pglogical library is located in the v16 folders, but not the v13 folders. I tried symlinking with

for i in $(ls /usr/share/postgresql/16/extension/pglogical*); do ln -s $i /usr/share/postgresql/13/extension/$(basename $i); done
ln -s /usr/lib/postgresql/16/lib/pglogical.so /usr/lib/postgresql/13/lib/

but that just leads to this error

FATAL: could not load library “/usr/lib/postgresql/13/lib/pglogical.so”:/usr/lib/postgresql/13/lib/pglogical.so: undefined symbol: shmem_request_hook

So the library files aren’t a 1:1 replacement between the different postgres versions.

In the end, it looks like there is a bit of a gap between the installed postgres version and the version the docker launcher things it’s building.

My end goal here is to get pglogical installed, and it would be most ideal to find a solution that is reproducible when rebuilding the container (i.e., files or lines that can be easily added to the template files). I definitely game and able to do more of the needed DevOps work here (as it is a requirement for my org), but am just curious if others have run into this gap and what you’ve done about it.

Thank you for reading!

Silly, silly, silly me. The reason the pglogical files are there are because I ran

sudo apt-get install postgresql-16-pglogical

to put them there. (It was a long day of DevOps yesterday.) Running a dpkg -L postgresql-16-pglogical pointed that out for me…

Running

sudo apt-get install postgresql-13-pglogical

got pglogical up and running for me no problem. I am going to keep exploring this further, but at least I am unblocked on my urgent task.

However, I think the point I make above about the versions in discourse_docker and postgres remains.

1 Like

Note that psql --version and docker exec data su postgres -c "echo 'select version();'|psql"|grep PostgreSQL|cut -d " " -f 3 are not the same thing.

I think that the image has up-to-date client tools (that work for people who are running later versions of postgres that Discourse (probably) supports) and hasn’t force everyone to update to PG15 or whatever the plan is just yet.