tianon / docker-postgres-upgrade

a PoC for using "pg_upgrade" inside Docker -- learn from it, adapt it for your needs; don't expect it to work as-is!
https://hub.docker.com/r/tianon/postgres-upgrade/
MIT License
1.04k stars 114 forks source link

pg_upgrade 12 to 14 with postgis - several hurdles - solved #45

Closed WinFinn closed 2 years ago

WinFinn commented 2 years ago

Just wanted to drop this in here as I had several issues during my upgrade, but managed to get through after a couple of days searching and failing. 1) There seems to be a postmaster servicing the old cluster. Please shutdown that postmaster and try again. see https://github.com/tianon/docker-postgres-upgrade/issues/15 I increased the shutdown period to 10min, but it was not enough. I had to run the 4 commands described in issue 15 above. 2) Next failure was with error ""no password supplied" This was fixed with by editing pg_hba.conf on original (v12) postgresql. Changed settings for the two "local" lines from my "md5" to "peer". (Note that changing the other to peer will genereate another error). See postgres official upgrade step7 (Adjust authentication). https://www.postgresql.org/docs/14/pgupgrade.html 3) Finally something started to happen. But as I had postgis extention installed I had to run the upgrade with this extentions. see https://github.com/tianon/docker-postgres-upgrade/issues/33 I build a new docker container for upgrade with the postgis extentions as explained above. 4) Next failure was during upgrade of the postgis extention: -- For binary upgrade, handle extension membership the hard way ALTER EXTENSION "postgis_sfcgal" ADD FUNCTION "public"."postgis_sfcgal_version"(); I could not find much information about this. But I ended up removing this extension on the databases that had it. and then create them again when the pg14 was up and running. I deleted and created these with pgadmin4 web ui. I suspect this failure might be due to incorrect versions of postgis in my upgrade docker vs the original PG12 docker. 5) when upgrade finally completed I had to change the PG14 pg_hba.conf file to get access again. basically I copied the file from v12, and changed back the "peer" changes made at failure 2 above. 6) finally getting the connections up with pgadmin4 to the new PG14 I created the postgis_sfcgal extension from failure 4 above, and also updated the extensions as suggested in the "update_exstensions.sql" generated by this docker_upgrade.

Hope this can help others that also has issues upgrading