Heroku Postgres Maintenance Windows
Last updated 21 March 2017
Table of Contents
From time to time, Heroku must take your database offline to perform maintenance tasks. Typical tasks include upgrading the underlying infrastructure of the database (for example, patching the operating system or required libraries) or upgrading Postgres itself. This maintenance is handled automatically by Heroku.
Maintenance windows are available for all production database plans.
Checking if maintenance is required for your database
You can check if maintenance is required on a database by using
$ heroku pg:info Plan: Standard 4 Status: Available Data Size: 26.1 MB ... Maintenance: required by 2014-02-01 00:00:00 +0000
Setting a maintenance window
Some database plans support maintenance windows that can be set. Users can specify the day-of-week and time (UTC) at which the maintenance will occur:
$ heroku pg:maintenance:window DATABASE "Sunday 14:30"
Setting a maintenance window allows you to minimize the impact on your application and users. We recommend selecting a time during which maintenance would have the least impact on your business. Maintenance windows are 4 hours long starting at the time you specify. The actual time required for maintenance depends on exactly what’s taking place, but it will usually require your database to be offline for only a few minutes.
Running a maintenance
For databases that support a maintenance window and have a maintenance that needs to occur, that maintenance can be run prior to the maintenance window. This will allow for the maintenance to occur on a time frame that you prefer if it happens to be outside the maintenance window.
If you run a maintenance, you must either put the application into maintenance mode or use the
--force flag to run maintenance without putting it the application in maintenance mode.
Putting application in maintenance mode
$ heroku maintenance:on -a sushi Enabling maintenance mode for ⬢ sushi... done $ heroku pg:maintenance:run DATABASE -a sushi Starting maintenance for postgresql-clean-29349... done $ heroku maintenance:off -a sushi Disabling maintenance mode for ⬢ sushi... done
Forcing a maintenance
Forcing a maintenance is an action that should be used with extreme caution. If the maintenance were to require some down time, your application could see errors from being unable to connect to the database.
$ heroku pg:maintenance:run DATABASE --force -a sushi
Maintenance windows that can be set and manual maintenance runs are only available on standard, premium and enterprise plans.
Heroku will make the best effort to honor your maintenance window request but it is not guaranteed. If there is an emergency where the security or integrity of your data is threatened, we may perform the maintenance outside of your regular window at our discretion.