sagemathinc / cocalc-docker

DEPRECATED (was -- Docker setup for running CoCalc as downloadable software on your own computer)
https://cocalc.com
Other
398 stars 103 forks source link

upgrade from postgres 10 to postgres 15 without breaking existing cocalc-docker installs #110

Open williamstein opened 3 years ago

haraldschilly commented 3 years ago

It's hard to do this automatically, because there could be a need for user intervention. There are three ingredients.

  1. there is a file PG_VERSION, containing 10, 13, or whatever else. The script has to decide what to do based on that.
  2. The command is pg_upgrade: 2x bindir and 2x datadir are mandatory, then first do --check to see if it works, then remove it and maybe use --link to make hardlinks. The hardlink variant is quicker, but there is no way back. So, a question here is, should this be done with a safety net or not. I would say yes.

    1. move the current data dir to data-10 for version 10
    2. execute pg_upgrade (first with --check) but without --link, targeting data
    3. if it works, get rid of the backup in data-10 – otherwise remove data, report the problem, and rename data-10 to data and start the DB as usual. Next time, it will attempt to upgrade again.
  3. configuration files. I haven't checked what docker configures, but there were params we had to change in production. wal_keep_size is new, while wal_keep_segments was removed: sed -i "/^wal_keep_segments/d" {PG_DATA}/postgresql.conf.

Oh, and in general, that new data dir must be setup fresh by the same user as the original database. IDK which one docker has, mabye postgres ? In any case, step one for ne new data dir is initdb -U [username], or maybe just the default, and step two is to copy over postgresql.conf and pg_hba.conf – or well, maybe we just write new config files and forget about copying and changing lines.