View a markdown version of this page

Upgrading a database cluster group for Aurora in waves - Amazon Aurora

Upgrading a database cluster group for Aurora in waves

In a database cluster group for Aurora, you upgrade the member clusters in waves with one group operation. You assign each member cluster to a wave, and the group upgrades one wave at a time. A minor version change then reaches your member clusters in an order that you choose. Group upgrades work with routing enabled or disabled. For Aurora MySQL versions and how a cluster upgrade works, see Database engine updates for Amazon Aurora MySQL.

How a wave upgrade works

A group upgrade covers minor engine versions, engine patches, and operating system updates. It runs in up to 10 waves within the group's maintenance window. Waves run in order, and the member clusters within a wave upgrade in parallel. A member cluster that you don't assign to a wave goes in the first wave. Before the upgrade starts, Aurora runs pre-upgrade checks on every member cluster, and the upgrade stops if any check fails. The group doesn't upgrade major versions: you upgrade them one member cluster at a time with existing Aurora operations, as described in Major version upgrades.

The group rejects an upgrade request unless the following conditions hold:

  • Every member cluster is available.

  • Every member cluster runs the same major version.

  • The target version is at or above the highest version that any member cluster runs.

  • No member cluster holds a staged cluster-level upgrade of the same type. After you stage a group upgrade, the group rejects a cluster-level upgrade of the same type the same way.

If a member cluster holds a staged cluster-level upgrade, apply that upgrade first, and then request the group upgrade. Operating system updates follow the same rule as engine upgrades.

The pre-upgrade checks run while every member cluster stays available. If a check fails, the upgrade stops before the group patches any member cluster. If an upgrade fails on a member cluster after patching starts, what happens next depends on the upgrade type, as the following table shows.

Upgrade When a member cluster fails
Aurora MySQL minor version upgrade The member cluster rolls back, and the upgrade stops, so the waves that didn't start don't run.
Aurora MySQL patch The member cluster rolls back, and the group upgrade stops, so the waves that didn't start don't run.
Operating system update The member cluster moves to a new host, and the remaining waves continue.

A failure inside a wave doesn't roll back the whole wave. A member cluster that reached the target version stays on it, the others stay on the source version, and the group stays usable. To finish, request the group upgrade again while every member cluster runs the same major version: only the member clusters that aren't on the target version upgrade. You can also upgrade them at the cluster level.

You can't cancel a started group upgrade, and it doesn't pause between waves for a bake time or a manual validation step. An upgrade that runs past the end of the maintenance window continues to completion, as on a single Aurora DB cluster, so assign waves that can finish inside your window. Automatic minor version upgrade isn't available for a group. To move a group to a new minor version, request a group upgrade.

Routed sessions during an upgrade

A minor version upgrade of a member cluster closes the routed sessions whose last statement went to that member cluster, with no error first. On Aurora MySQL, the next statement in such a session returns error 2013 (Lost connection to MySQL server during query). The upgrade rolls back an open transaction on that member cluster. Reconnect to the routing endpoint and retry, and make sure that your retry logic also handles a connection that closes with no error. For retries, see Retrying after an error.

The patch keeps direct connections to the member cluster, and it doesn't affect statements for the other member clusters. The member clusters in a wave upgrade in parallel. If every member cluster is in the first wave, routed sessions across the whole group close at about the same time. To limit the effect, assign the member clusters to more than one wave, as described in Assigning upgrade waves.

The routing layer isn't part of a group upgrade. AWS patches it separately, on a schedule that AWS controls. It doesn't use the group's maintenance window, and you can't move its patching into that window.

Assigning upgrade waves

Each member cluster has an upgrade wave, an integer from 1 to 10, that you set per member cluster. You set it when you add the cluster to the group, with AddDBClusterToDBClusterGroup, or later with ModifyDBCluster (aws rds modify-db-cluster) and --db-cluster-group-upgrade-wave. You can't set it when you create a cluster. DescribeDBClusters returns each member cluster's wave in DBClusterGroupUpgradeWave.

To limit the effect of a failed upgrade, put a small number of member clusters in the first wave, and spread the others over later waves. Assign waves so that the upgrade can complete inside your maintenance window.

To assign an upgrade wave
  1. With the console, the AWS CLI, or the Amazon RDS API, set the member cluster's wave, as shown in the following tabs.

  2. With the AWS CLI, call DescribeDBClusters for the member cluster, and check DBClusterGroupUpgradeWave.

Console
To set the upgrade wave of a member cluster (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Database cluster groups, and then choose the group.

  3. On the Member clusters tab, select the member cluster.

  4. Choose Actions, and then choose Edit upgrade wave.

  5. Choose the wave. Lower-numbered waves run first.

  6. Save the change.

To see the wave of each member cluster, view the Upgrade waves section on the group's Maintenance & backups tab.

AWS CLI
aws rds modify-db-cluster --region REGION --db-cluster-identifier CLUSTER_IDENTIFIER \ --db-cluster-group-upgrade-wave WAVE aws rds describe-db-clusters --region REGION --db-cluster-identifier CLUSTER_IDENTIFIER \ --query 'DBClusters[0].DBClusterGroupUpgradeWave'
Amazon RDS API

Call ModifyDBCluster with DBClusterIdentifier and DBClusterGroupUpgradeWave. Read the wave back from DBClusterGroupUpgradeWave in DescribeDBClusters.

Note

You must specify a wave number from 1 to 10.

Upgrading a group

The following procedure upgrades every member cluster wave by wave and confirms routing to each member cluster as it finishes.

Before you begin

To upgrade a group
  1. With the AWS CLI, take a group snapshot, as described in Creating a snapshot of a database cluster group for Aurora. Check that its SnapshotDatabaseTime is later than your last mapping change.

  2. With the AWS CLI, choose a valid minor target version, as you do for a single cluster. For the versions and how to list valid upgrade targets, see Database engine updates for Amazon Aurora MySQL.

  3. With the AWS CLI, check each member cluster's wave against your plan, and change any that differ, as described in Assigning upgrade waves.

  4. With the AWS CLI or the Amazon RDS API, request the group upgrade with the target version, as shown in the first set of tabs after this procedure. Without --apply-immediately, the upgrade starts in the group's maintenance window, and PendingModifiedValues shows the target until then.

  5. With the AWS CLI, follow progress with the status of the group and of each member cluster, each member cluster's EngineVersion, and the group's MinEngineVersion and MaxEngineVersion. Each member cluster also emits Amazon RDS events when its upgrade starts and when it completes. For events, see Amazon RDS events for database cluster groups for Aurora.

    aws rds describe-db-clusters --region REGION --db-cluster-identifier CLUSTER_IDENTIFIER \ --query 'DBClusters[0].[Status,EngineVersion]' --output text
  6. At the routing endpoint, as each member cluster reaches the target version and reads available, check it without waiting for the last wave. Confirm that it's listed in dbclustergroup_sys.member_cluster_mappings, that a pin to it returns its new version, and that one routed read per mapping on it returns rows. The pin statement follows the second set of tabs after this procedure.

AWS CLI
aws rds modify-db-cluster-group --region REGION --db-cluster-group-identifier GROUP_IDENTIFIER \ --engine-version TARGET_ENGINE_VERSION --apply-immediately
Amazon RDS API

Call ModifyDBClusterGroup with DBClusterGroupIdentifier and EngineVersion. To start the upgrade now instead of in the maintenance window, also pass ApplyImmediately.

Step 6. At the routing endpoint, pin a session to the upgraded member cluster, read its host name and version, and clear the pin.

SET SESSION router_cluster_pin = 'MEMBER_CLUSTER_ALIAS'; SELECT @@hostname, @@aurora_version; SET SESSION router_cluster_pin = DEFAULT;

The upgrade is complete when the group reads available with PendingModifiedValues empty and every member cluster is on the target version. If a member cluster didn't reach the target version, request the group upgrade again, as described in How a wave upgrade works.

Reading the progress of an upgrade

The group's MinEngineVersion and MaxEngineVersion in DescribeDBClusterGroups are the lowest and the highest version strings that the member clusters run. When they're equal, every member cluster runs the same version. During a group upgrade, they change as each wave completes. If they differ, read each member cluster's EngineVersion with DescribeDBClusters.

The upgrade begins at the start of the maintenance window. To follow it, check the status of the group with DescribeDBClusterGroups and of each member cluster with DescribeDBClusters. The Amazon RDS events that each member cluster emits during its upgrade describe direct connections to it only. A message that says the cluster remains online, and the counts of preserved and dropped connections in the completion event, don't include routed sessions. The upgrade closes routed sessions, as described in How a wave upgrade works.

Maintenance window and pending maintenance

A group has its own preferred maintenance window. A group upgrade that you stage runs in that window, not in each member cluster's window. To set it, call ModifyDBClusterGroup with --preferred-maintenance-window, in the format that Aurora uses, for example wed:04:52-wed:05:22, and read it back from PreferredMaintenanceWindow in DescribeDBClusterGroups. For the group settings, see Changing group settings.

To apply a pending engine patch or operating system update in the group's maintenance window, call ApplyPendingMaintenanceAction with the group's ARN in --resource-identifier, the action in --apply-action, and next-maintenance in --opt-in-type. The ARN is the DBClusterGroupArn value from DescribeDBClusterGroups. The group identifier isn't accepted, and fails with InvalidParameterValue. The group applies the latest available version for each member cluster, even when the member clusters run different versions. For the maintenance model, see Maintaining an Amazon Aurora DB cluster.

To apply pending maintenance to a group (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Database cluster groups, and then choose the group.

  3. On the Maintenance & backups tab, under Pending maintenance, select the action. You can apply Engine patch and OS upgrade actions to a group.

  4. Choose whether to apply the action now or in the next maintenance window.

  5. Confirm the action. The group applies an engine patch to the member clusters one wave at a time.

Major version upgrades

A group upgrade doesn't change the major version. Upgrade one member cluster at a time with the existing Aurora operations, as you upgrade a standalone Aurora DB cluster, while the other member clusters keep serving traffic. For the procedures, see Upgrading the major version of an Amazon Aurora MySQL DB cluster. After each member cluster, check its EngineVersion with DescribeDBClusters before you start the next one. During the transition, a group can contain at most two major engine versions, and the group rejects a group upgrade request because the member clusters don't share a major version. The routing layer reports the MySQL version of the group's MinEngineVersion, for example 8.4.900 for 8.4.mysql_aurora.8.4.900, in the connection handshake and from VERSION() and @@version. You don't run an operation to update it.