Sub topic 13
Maintenance windows and engine upgrades
This chapter assumes you have created an RDS instance, understand Multi-AZ deployments, and know how parameter groups work. RDS patches the operating system and database engine for you, but you choose when it happens and which engine versions you run.
What RDS maintains
RDS applies two kinds of changes during a maintenance window:
- Operating system and host updates, such as security patches and hardware replacement.
- Minor engine version upgrades, if you have turned on automatic minor version upgrades.
A maintenance window is a weekly block of at least 30 minutes that you pick. Outside that block, RDS does not start routine maintenance. Some updates are marked "required" and will be applied on a schedule AWS sets, so you can postpone them only for a limited time.
Setting the window
If you do not choose a window, RDS assigns a random 30-minute slot in your Region. Pick a low-traffic period instead.
aws rds modify-db-instance \
--db-instance-identifier demo-pg \
--preferred-maintenance-window "sun:04:00-sun:04:30" \
--auto-minor-version-upgrade \
--apply-immediatelyThe window is in UTC. Use the format ddd:hh24:mi-ddd:hh24:mi. The backup window must not overlap it.
You can list pending maintenance actions at any time:
aws rds describe-pending-maintenance-actions \
--filters Name=db-instance-id,Values=demo-pgHow Multi-AZ changes the impact
On a Multi-AZ instance, RDS patches the standby first, fails over to it, and then patches the old primary. You see a short failover, usually one to two minutes, instead of a full outage. On a Single-AZ instance, the database is unavailable while the update runs.
Minor and major upgrades
| Type | Example | Compatibility | How it happens |
|---|---|---|---|
| Minor | PostgreSQL 16.3 to 16.4 | Backward compatible | Can be automatic in the window |
| Major | PostgreSQL 15 to 16 | May change behavior or remove features | Always started by you |
Automatic minor upgrades never perform a major upgrade. A major upgrade takes the instance offline for its duration, and you cannot roll it back. If it goes wrong, you restore from a snapshot.
To start a major upgrade, you specify a target version and, because parameter groups are tied to an engine family, a new custom parameter group:
aws rds modify-db-instance \
--db-instance-identifier demo-pg \
--engine-version 16.4 \
--allow-major-version-upgrade \
--db-parameter-group-name demo-pg16 \
--apply-immediatelyThe parameter group's family must match the target version. For example, demo-pg16 from the previous chapter has family postgres16.
Common errors
- Upgrading production directly. Restore a recent snapshot to a new instance, upgrade that copy, and run your application's tests against it first.
- Forgetting the parameter group family. The upgrade fails or the instance keeps the old defaults if you do not supply a matching group.
- Using
--apply-immediatelyby accident. This skips the window and can cause downtime during business hours. Omit it to queue the change for the next window. - Running an engine version past end of standard support. RDS may upgrade it for you, or charge extra for extended support, depending on the engine.
Exercise
Your Single-AZ production database must not go down on Tuesday mornings. A required patch is pending. What two things can you do to control when it applies, and what do you accept?
Show answer
Change the preferred maintenance window to a quiet period (for example Sunday at 04:00 UTC) so RDS applies the patch there, and consider converting to Multi-AZ so the patch causes only a brief failover. You accept that required patches cannot be deferred forever, and that on Single-AZ the instance is unavailable while the patch applies.