The only scenario I can think of is NOT restarting postgres after the
package update. This could happen when postgres process is managed
outside of init(systemd) such as pacemaker, etc. for HA purposes.

$ sudo lsof / | grep plpgsql.so
postgres  21822         postgres  DEL    REG  252,1          1295136 
/usr/lib/postgresql/12/lib/plpgsql.so
postgres  21948         postgres  DEL    REG  252,1          1295136 
/usr/lib/postgresql/12/lib/plpgsql.so

For a single node scenario with systemd, postgres can be restarted in
the postinst of the postgres-common package so there should be no
orphaned library in memory. So this might not be related to MAAS snap or
postgres packages, but to a simple fact that postgres needs to be
restarted after a package update (especially when it's managed by
something like pacemaker than systemd itself).


[steps to reproduce on a fresh machine/VM]

$ sudo apt update && sudo apt upgrade -y

$ cat <<EOF | sudo tee /etc/apt/preferences.d/pin-to-release
Package: *
Pin: release a=*-updates
Pin-Priority: 400

Package: *
Pin: release a=*-security
Pin-Priority: 400
EOF

Then, set up MAAS with "Initialise MAAS for a production configuration" using 
postgres deb packages.
https://maas.io/docs/snap/2.9/ui/maas-installation

Switch to pg_ctl simulating pacemaker scenario.

$ sudo systemctl stop postgresql.service
$ sudo systemctl disable postgresql.service

$ sudo -u postgres touch /var/lib/postgresql/12/main/postgresql.conf
$ sudo cat /etc/postgresql/12/main/pg_hba.conf | sudo -u postgres tee 
/var/lib/postgresql/12/main/pg_hba.conf

$ sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl start -D
/var/lib/postgresql/12/main/

Unpinning and upgrade:
$ sudo rm /etc/apt/preferences.d/pin-to-release
$ sudo apt upgrade

Then, I see "DEL" status in lsof and the actual errors.

$ sudo lsof / | grep plpgsql.so
postgres  21822         postgres  DEL    REG  252,1          1295136 
/usr/lib/postgresql/12/lib/plpgsql.so
postgres  21948         postgres  DEL    REG  252,1          1295136 
/usr/lib/postgresql/12/lib/plpgsql.so

$ sudo service snap.maas.supervisor restart                                     
                                                                                
                          2021-08-16 11:47:02.241 GMT [24009] ERROR:  could not 
load library "/usr/lib/postgresql/12/lib/plpgsql.so": 
/usr/lib/postgresql/12/lib/plpgsql.so: undefined symbol: 
EnsurePortalSnapshotExists
2021-08-16 11:47:02.241 GMT [24009] STATEMENT:  UPDATE "maasserver_node" SET 
"managing_process_id" = NULL WHERE "maasserver_node"."id" IN (1)
2021-08-16 11:47:02.245 GMT [24007] ERROR:  could not load library 
"/usr/lib/postgresql/12/lib/plpgsql.so": /usr/lib/postgresql/12/lib/plpgsql.so: 
undefined symbol: 

After restarting postgresql explicitly, the error has gone:

$ sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl restart -D 
/var/lib/postgresql/12/main/
### ^^^ this should be done through crm or equivalent instead of invoking 
pg_ctl directly for production.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1939898

Title:
  Unnatended postgresql-12 upgrade caused MAAS internal error

To manage notifications about this bug go to:
https://bugs.launchpad.net/maas/+bug/1939898/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to