Do I need to do anything to perform the Heroku Postgres maintenance?

Issue

You are wondering if you need to do anything to perform the Heroku Postgres maintenance.

Resolution

There are three different ways for maintenance to occur. The most common way is to do let Heroku perform the maintenance for you. We use your databases maintenance window to determine the best time to run this maintenance automatically.

If you wish to run your maintenance manually you can do so in one of two ways. Via heroku pg:maintenance --force. This will immediately fail over to your HA follower or the hidden follower if it has been caught up. Your application will immediately restart and be pointed to the new follower.

The other method involves putting your application into maintenance mode before performing the PostgreSQL failover. This can have benefits such as providing a clean landing page for your users, but total downtime can be longer as it is a manual process to enable and disable maintenance mode. We have more detailed information on the maintenance mode page.

There are two ways this maintenance can happen: automatically by us, or manually by you.

Automatically

The most common way is to let Heroku perform the maintenance for you. We use your databases maintenance window to determine the best time to run this maintenance automatically. If you want it to happen automatically, you do not need to do anything. Your app restarts as part of the maintenance process, so some users may see errors or delays for a minute or three.

Note: You may see these errors in your logs: connection error, pg is read only, etc. These are artifacts of the changeover process and are safe to ignore as long as everything comes back online.

Manually by you

If you want to have better control over your user experience during the maintenance, you can do it yourself. To perform the maintenance, run the heroku pg:maintenance:run DATABASE --force -a sushi command at any time before your scheduled maintenance.

You may want to use maintenance mode to turn off the app while the maintenance runs to minimize the errors your users see. That might look something like:

heroku maintenance:on
heroku pg:maintenance:run --force
heroku pg:wait
heroku maintenance:off

If you have built a read-only or database-independent mode into your app, you could use that as well:

# for example
heroku config:set READ_ONLY=true
heroku pg:maintenance:run --force
heroku pg:wait
heroku config:set READ_ONLY=false

See Maintenance Types for more information on running the maintenance manually.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support