upgrading postgres version on Heroku, why upgrade the follower? - postgresql

Heroku has instructions on how to upgrade postgres database version.
At a high level it's the following:
provision a follower database (to follow primary db)
put app into maintenance mode (so no new db transactions)
upgrade follower
promote follower to primary
My question is - why is it recommended to upgrade the follower? Why not just upgrade the primary db? Then we wouldn't need to promote the follower either.
I can see it's useful to have the follower as a backup incase the upgrade fails but I'm not clear on why we upgrade and promote the follower.

Related

Postgres Publication record is showing up in standby too

Is there anyway we can avoid creating publication record from master to slave? I am trying to upgrade postgres version in standby by using pg_wal_replay_pause() still i could see records are comping up from master.

Validating the postgres upgrade using logical replication

Currently I am trying to upgrade my postgres 9.1 to 10 using logical replication. As 9.1 does not support native logical_replication, I tried slony and made a replica successfully.
P.S. The above replica I created is using a sample dump from an year ago which is only of 800mb.
Now I have few questions.
How can I validate whether the replica has all the data replicated successfully. Few suggested to put the master on maintenance mode(few downtime) and do a last N items comparison with both the database on all the tables.
I tried with 800mb. Will there be any problem when I go and try with 100+ GB?
Please share your personal experience here. I have been trying to document what are the things that could go wrong so I can always try to anticipate the next course of action.
You may use the Data Validator that is shipped with trial version of EDB Postgres Replication server for validating the data between old and new PostgreSQL databases.
You may read the details of Data Validator at Data Validator Document
To download the EDB Replication Server please follow this link: EDB Replication Server
Disclosure: I work for EnterpriseDB (EDB)

Upgrading Postgres Aurora Major Version

According to:
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.Upgrading.html
Manually Upgrading the Engine Version
To perform a major version upgrade of a DB cluster, you can restore a
snapshot of the DB cluster and specify a higher major engine version.
For information about restoring a DB cluster, see Restoring from a DB
Cluster Snapshot.
Yet I don't see anywhere the option of choosing a database engine at restore.
Is the documentation incorrect?
Am I missing something?
This is now supported by Aurora Postgres. There is no need to restore a snapshot into a new cluster anymore. The procedure is explained in the documentation.
As of 2020/05/22:
"Currently, you can do a major version upgrade from Aurora PostgreSQL version 9.6.11 or 9.6.12 database clusters to Aurora PostgreSQL version 10.11."
I also encountered the same issue when attempting to upgrade Aurora Postgres from 9.x to 10.x. The GUI and aws-cli does not allow you to specify a higher version number when restoring a snapshot.
AWS support confirms this is NOT supported at this time, this from my chat session with the tech:
I should have recollected earlier. Currently there isn't an in-place upgrade path from Aurora 9.x to version 10.
This is something that is frequently requested for and the engineering team is working on but we don't have an ETA as to when this will be fixed.
AWS did offer two options:
Use pg_dump and pg_restore to extract and load the data into an upgrade target cluster.
Use AWS Data Migration Services to migrate data. DMS has the advantage of minimal downtime but it comes with many limitations you would have to evaluate. For example some data types, like JSON and timestamps with time zones are 'partially migrated'.
Links to AWS DMS documentation using PostgreSQL as a source and/or target of DMS:
Postgres as DMS Source: https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Source.PostgreSQL.html#CHAP_Source.PostgreSQL.Homogeneous.DMS
Postgres as DMS Target:
https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.PostgreSQL.html
The tech I chatted with favored pg_dump/pg_restore because it's more native, but it involve more downtime.

Patching without downtime in postgres

Just wanted to know if i'm patching my postgres database and I should not have any downtime whatsoever what should i do ? (I'm patching both my Master and Slave Databases)
If you don't mind running modified PostgreSQL servers, you can run a cluster solution like BDR or Postgres-XL.
With standard PostgreSQL, you can use streaming replication. First upgrade the standby, then manually fail over to the standby, upgrade the primary and use it as new standby server.
All these solutions require that you have a connection pooler like pgBouncer that allows you to redirect client connections between the servers.

Postgres Upgrade Heroku from 9.2.4 to 9.3

I am fairly new to Rails and especially Heroku. I received an email informing me that I needed to update my PostgreSQL DB version. I am a little fuzzy on how to accomplish this without changing my plan. I am currently using Heroku's Kappa Postgres plan. Based on what I am reading here:
https://devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups
Should I use the command:
heroku addons:add heroku-postgresql:kappa --version 9.3
And then just continue on as instructed?
Just doing this myself, from 9.2.4 databases ...
You don't have to upgrade to 9.3, you can just create a new 9.2 and it will be 9.2.6, in which the issue you're being notified about has been fixed. However if you go to 9.3 the plans are different -- https://devcenter.heroku.com/articles/heroku-postgres-plans#standard-tier
It's more simple/safe to upgrade with a follower database. Instructions here, although you probably want to add your app name to most of those commands. https://devcenter.heroku.com/articles/heroku-postgres-follower-databases#database-upgrades-and-migrations-with-changeovers