What Both Versions Must Read for Rollback Safety - Two-Phase Deployment and the State a Rollback Leaves Behind
First Published:
Last Updated:
Amazon Builders' Library's "Ensuring rollback safety during deployments" states this condition clearly: the new version must be able to read data written by the old version, and vice versa. This article applies this principle to AWS components. For each deployment mechanism, it separates what the pages say a rollback returns from what they do not say it returns. It then separates, for each place where state is kept, the direction in which the old version reads what the new version wrote from the direction in which the new version reads what the old version wrote. Finally, it covers two-phase deployment, a strategy for splitting unrollable changes across two deployments, and upgrade-downgrade testing, a method for validating rollbacks through testing.
This article is based on documents read on December 3, 2026 (during re:Invent 2026) and does not include any real-world measurements. It does not cover database schema change procedures, the details of RDS Blue/Green deployments, or pricing.
Related articles on this site:
- Zero-Downtime Database Change on RDS and Aurora - Blue/Green Deployments, Upgrades, and Rollback Design
- What an Agent Release Contains on AgentCore - Runtime Versions, Endpoints, and Parts Outside the Version
- Amazon ECS Deployment Lifecycle - Early Success Criteria, Deferred Cleanup, and Managed Daemon Rollouts
- Cell-Based Architecture and Shuffle Sharding on AWS - Blast Radius Reduction Patterns for Large-Scale Workloads
Table of Contents
- 1. Scope and Assumptions
- 2. What Rollback Restores, and What It Does Not
- 3. Both the Old and New Versions Must Read
- 4. Two-Phase Deployment and Backfilling
- 5. The Unit Each Deployment Mechanism Rolls Back
- 6. What Both Versions Read, by Where State Is Kept
- 7. When to Roll Forward and When to Split a Change That Cannot Be Rolled Back
- 8. Verifying Rollback in Testing
- 9. Frequently Asked Questions About Rollback Safety
- 10. Summary
- 11. References
1. Scope and Assumptions
This chapter first sets out the readers, the scope, the materials read, the statement labels, and the use of terms. The conclusions, given first, are the following seven.- What AWS deployment mechanisms roll back is code, configuration, where traffic goes, and the stack configuration. None of the pages this article read says a rollback returns the state that the new version wrote (Chapter 2).
- After a rollback, the old version reads what the new version wrote. While the versions are mixed before a rollback, both directions occur at the same time (Chapter 3).
- Changes that simultaneously modify both the reading and writing processes may be unrollable. Builders' Library addresses this by splitting such changes into two separate deployments: one to update the reading process and another to modify the writing process. While each deployment can be rolled back individually, they cannot be rolled back together (Chapter 4).
- CodeDeploy redeploys the previous revision as a new deployment. The page on Blue/Green deployments using logical replication in RDS for PostgreSQL says that rows the application writes to green during the switchover after overriding the read-only setting are not in blue if the switchover rolls back. The same applies to Aurora PostgreSQL (Section 2.3, Chapter 5).
- SQS messages remain for up to 14 days, and EventBridge archive events remain indefinitely by default. Cached values remain until their TTL expires. A compatibility mode in AWS Glue Schema Registry is chosen by which direction's readers it protects (Chapter 6).
- The Well-Architected Framework's OPS04-BP02 recommends that, for a change that has altered persistent state that rollback cannot cleanly reverse, it may be safer to apply a fix and move forward (Chapter 7).
- You verify rollback safety through testing that involves running both the old and new versions concurrently, followed by executing the rollback process (Chapter 8).
1.1 Target Audience
This article is written for architects, Site Reliability Engineers (SREs), and platform engineers who use Lambda aliases, CodeDeploy, ECS circuit breakers, and CloudFormation rollbacks in production. In particular, it is written for those who think they can roll back because a rollback mechanism exists, but who have not checked whether the rolled-back old version can read the messages the new version sent to queues, the values it wrote to caches, or the columns it added to the database.1.2 What This Article Covers and What It Does Not
This article covers the following aspects: what is rolled back and what is not, read and write directions, two-phase deployment, bake periods, and backfilling, serializers that keep unknown attributes, the unit each deployment mechanism rolls back, reads and writes by where state is kept, the directions of Glue Schema Registry compatibility modes, roll forward, upgrade-downgrade testing, and the checked date.The following topics are not covered here, with the articles that cover them:
- Procedures for database schema changes, and the periods before and after the switchover of RDS and Aurora Blue/Green deployments: Chapters 6 and 10 of Zero-Downtime Database Change on RDS and Aurora.
- Items that are not rolled back, even when the AgentCore endpoint is rolled back: Chapter 6 of What an Agent Release Contains on AgentCore.
- Switching and rolling back foundation models: Safe Foundation Model Rollout Strategies on AWS.
- Defining successful deployments in Amazon ECS, and actions that can negate that success: Chapter 5 of Amazon ECS Deployment Lifecycle.
- Designing schemas for streams: Section 8.1 of AWS Real-Time Streaming Data Pipeline Architecture Guide.
- The change to CloudFormation's default rollback behavior: Chapter 3 of Express Mode and Pre-Deployment Validation in AWS CloudFormation.
This article does not cover EKS cluster version rollbacks, phased deployments to cells, support windows for language and framework versions, or pricing.
1.3 Checked Date and Reviewed Materials
The checked date is December 3, 2026. This date falls within the re:Invent 2026 conference (November 30 to December 4, 2026), and the content reviewed in this article may change during the conference period. Based on searches of AWS What's New, no announcements during the conference period were found that would alter the rollback behavior of the components discussed in this article.The materials read fall into the following three categories:
| Category | Role in this Article | Reviewed Materials |
|---|---|---|
| Amazon Builders' Library | Amazon's experience (rules of thumb). Not AWS component specifications. | Ensuring rollback safety during deployments (published December 5, 2019) |
| AWS Well-Architected Framework and DevOps Guidance | AWS recommendations | OPS04-BP02, REL08-BP04, and REL08-BP05 in the version that consolidated the six pillars into one on November 16, 2026, and DL.ADS.2 in DevOps Guidance |
| Service Developer Guides and API References | Component specifications (rollback units, default values, ranges) | Lambda, CodeDeploy, ECS, CloudFormation, RDS, Aurora, SQS, EventBridge, ElastiCache, AWS Glue |
The Amazon Builders' Library page redirects from
aws.amazon.com/builders-library/ to the AWS Builder Center (builder.aws.com). The page displays Sandeep Pokkunuri as the author, and includes a disclaimer stating that the opinions in the article are the author's own and may not reflect those of AWS. While previous, pillar-specific pages for the Well-Architected Framework remain available, this article uses the consolidated version's URL and content. This article uses the official AWS blog only for reverting after the switchover of an RDS Blue/Green deployment (Section 5.6).1.4 Statement Labels
This article puts one of three labels on each statement:| Label | Meaning |
|---|---|
| Stated | Found in AWS documentation (Builders' Library, Well-Architected Framework, DevOps Guidance, developer guides, API references, What's New, and the official AWS blog). |
| Not stated | Not found within the documents reviewed for this article. This does not constitute proof of non-existence. |
| Inference | Derived by this article based on the information presented in the documents. |
Within Stated, the strength of the statement varies depending on the source. Statements from the Builders' Library are based on the experience of Amazon teams and are written with
we as the subject. Statements from the Well-Architected Framework and DevOps Guidance represent AWS recommendations. Statements from developer guides and API references describe component specifications. This article names the source type for each statement and will not present experience or recommendations as specifications.1.5 Usage of Terms
This article distinguishes between the following terms:- Version: Refers specifically to deployed code. A "new" version refers to the code deployed in this instance, while an "old" version refers to the code that was previously running. Schema versions are always called schema versions to keep them apart.
- Rollback: Returning to an older version of the code and configuration. This includes redirecting traffic to the older version.
- Roll forward: Moving forward by deploying an even newer version that fixes the problem.
- State: Data that persists outside of the deployed code. This includes database rows and columns, messages within queues, archive events, cached values, and schema versions in a schema registry.
- Writer and Reader: The version of the code that writes the state, and the version that reads it.
- Backwards compatible: In the context of Builders' Library, this refers to a version that can be rolled back to the previous version without errors (Section 3.1). It is a different term from the
BACKWARDcompatibility mode in Glue Schema Registry (Section 6.5).
This article calls the read and write directions by the following two names:
- new writes, old reads: The direction in which the old version reads what the new version wrote.
- old writes, new reads: The direction in which the new version reads what the old version wrote.
2. What Rollback Restores, and What It Does Not
This chapter will first outline what rollback restores and what it leaves unchanged. Chapters 5 and 6 cover the details for each component.2.1 What Rolls Back: Code, Configuration, and Where Traffic Goes
The pages for AWS deployment mechanisms list the following as what a rollback returns (Stated, developer guides). A Lambda alias returns its pointer to a function version. CodeDeploy redeploys the previous revision. ECS circuit breakers revert to the previously completed deployment. CloudFormation rolls back the stack to its last stable state. This article refers to these collectively as deployment units (Inference).The Well-Architected Framework's REL08-BP04 recommends immutable infrastructure, which involves creating a new set of resources with each change and then shifting traffic to it. It then describes rollback as follows (Stated, recommendation).
You can roll back by directing traffic to the previous, unchanged set of resources.
The sentence says that you can roll back by pointing traffic back at the previous set of resources, which has not changed. What has not changed here is the previous set of resources, which an earlier deployment built. State shared by the old and new sets, such as databases, queues, and caches, is outside the sets (Inference).
2.2 What Remains: State Outside the Deployment
What the new version wrote while it ran is outside the deployment unit. None of the deployment mechanism pages this article read says it returns that state (Not stated). It is safest to assume that database rows, queue messages, archived events, cached values, and schema versions will persist even after a rollback (Inference).Figure 1 illustrates this distinction. The left side shows what the deployment mechanism reverts, the right side shows what may remain, and the center shows that the rolled-back old version must read what remains on the right.

2.3 What the Pages Say a Rollback Does Not Return
Two pages state explicitly what a rollback does not return.The first is CodeDeploy. The CodeDeploy user guide states (Stated, specification):
CodeDeploy rolls back deployments by redeploying a previously deployed revision of an application as a new deployment. These rolled-back deployments are technically new deployments, with new deployment IDs, rather than restored versions of a previous deployment.
Instead of reverting to a previous deployment, a rollback utilizes a previous revision to create a new deployment. For EC2 and on-premises deployments, you must choose how to handle files that remain on the target server and were not part of the previous deployment: either fail the deployment, overwrite them, or leave them as they are (Stated, specification).
The second example involves Blue/Green deployments using logical replication in RDS for PostgreSQL. A similar statement appears in the documentation for Aurora PostgreSQL. During the switchover, the writer instance in green has
default_transaction_read_only set to on, which blocks writes. If the application overrides this value to off at the session level, it can write to the green environment during the switchover. The page then says the following (Stated, specification).In the event the switchover has to roll back, these writes are not available in the blue environment, requiring you to manually resolve the data inconsistencies.
A rollback of the switchover does not carry the rows written to green during the switchover back to blue. You resolve the inconsistencies by hand. Among the pages this article read, this is the clearest statement of a rollback that returns the deployment unit but not the state written in the meantime.
3. Both the Old and New Versions Must Read
This chapter builds, from the premise in Builders' Library, what the old version reads after a rollback.3.1 The Premise in Builders' Library
The Builders' Library article calls a version that can be rolled back without errors backwards compatible (Stated, experience).A version of software that can be rolled back without errors or disruption to the functionality available in the previous version is called backwards compatible.
It then says the following about software that runs as one process on one device (Stated, experience).
If the standalone software maintains state, then the new version must read (that is, deserialize) data written (that is, serialized) by the old version and vice versa.
Deploying a single process never runs two versions at once. Even so, if it maintains state, the new version must be able to read data written by the old version, and the old version must be able to read data written by the new version. The latter is what occurs after a rollback.
3.2 In Distributed Systems, Readers and Writers Run Different Versions
Builders' Library describes deploying a distributed system as a rolling update, which moves hosts to the new version a few at a time (Stated, experience). When hosts interact with each other via RPC or shared persistent state, the writer and reader may run different versions.In the context of AWS components, two versions run concurrently in the following scenarios (Inference):
- When traffic is being routed between two versions of a Lambda function using weighted aliases.
- During an ECS rolling update and during the bake time of a blue/green deployment.
- During the canary and linear deployment phases of CodeDeploy.
- When the sender and receiver of a queue are deployed separately.
During these periods, both new writes, old reads and old writes, new reads can occur simultaneously. After a rollback, only the old version is running, so new writes, old reads occurs for the state left behind.
3.3 The Most Common Reason a Rollback Is Blocked
Builders' Library states the most common reason a rollback is not possible as follows (Stated, experience).We found that the most common reason for not being able to roll back is a change of protocol.
The article gives two examples. The first is a change that involves beginning to compress data written to the disk. Once the new version writes compressed data, the old version no longer knows how to decompress the data it reads, making rollback impossible. The second example is a change that extends the interval for heartbeats between servers from 5 seconds to 10 seconds. While it may seem like a change involving only a single number, during deployment, servers running the old version see no heartbeat for more than five seconds and close the connection from the new versions of the servers (Stated, experience).
The second example illustrates that even if the change doesn't leave a trace on the disk, a difference in what the two versions expect can break the mix of versions before any rollback. Builders' Library says Amazon verifies, for each deployment, that both rolling forward and rolling back are safe, as these kinds of changes can be difficult to detect even by reviewing the code or design documentation (Stated, experience).
3.4 Table 1: Read and Write Directions, and When They Occur
Table 1 sorts Sections 3.1 through 3.3 by direction (Inference).| Direction | Scenario | Potential Issue |
|---|---|---|
| old writes, new reads | During and after a forward-moving deployment, where the older version writes data that the newer version reads. | The newer version assumes required columns or attributes that the older data does not have. |
| new writes, old reads | During a forward-moving deployment, or after a rollback, where the newer version writes data that the older version reads. | The older version cannot read new formats (e.g., compressed data, different formats, unknown attributes). |
Tests of a forward deployment mainly exercise old writes, new reads. The new writes, old reads direction that occurs only after a rollback is not exercised by a test unless the test runs the rollback (Inference). Chapter 8 covers how to exercise this direction in a test.
4. Two-Phase Deployment and Backfilling
This chapter discusses two-phase deployment, a technique described in the Builders' Library. It splits a change that alters both how data is read and how it is written into two deployments, each of which can be rolled back. Everything below is written as Amazon's experience (Stated, experience).4.1 Example: From XML to JSON
The example scenario involves a service that reads and writes data to Amazon S3, and its task is to convert the data format from XML to JSON. The service operates across a cluster of servers in multiple Availability Zones. If the change is made in one deployment, the servers that receive the update will write data in JSON format, while those that haven't received the update yet are unable to read JSON. Therefore, the change is split into two parts.4.2 Prepare: Make the New Format Readable, Keep Writing the Old One
The first phase is called Prepare. In this phase, version V2 is deployed, ensuring that all servers can read both XML and JSON, while continuing to write data in XML format. From an operational perspective, nothing changes. If this phase is rolled back, the servers will revert to a state where they can no longer read JSON, but since no JSON-formatted data exists yet, this poses no issue.The article says that, at the end of the Prepare phase, Amazon explicitly verifies that all servers have received the change. Many deployment tools consider a deployment successful if a minimum number of hosts are healthy. The article uses CodeDeploy's
minimumHealthyHosts as an example. If even one server is left without Prepare, it cannot read JSON in the next phase.4.3 Bake Period: Leaving Time Between the Two Phases
The article says that each of the two phases can be rolled back, but not both changes together.While each of the two phases is safe for rolling back, we can’t roll back both changes.
After the Activate phase, the servers write JSON. The version prior to Prepare cannot read JSON. So enough time is left between Prepare and Activate to make sure that a rollback to the version before Prepare is not needed. The article calls this period the bake period, which typically lasts for a few days.
The term bake time is also used in ECS blue/green deployments, but it has a different meaning. In ECS, bake time refers to the period after live traffic has been shifted, during which both the old and new versions are running; it is a setting of the deployment mechanism (Section 5.4). The bake period in Builders' Library is operational time left between the two deployments.
4.4 Activate: Changing How Data Is Written
The second phase is called Activate. Version V3 is deployed, and the servers begin writing data in JSON format. Even servers that haven't yet received V3 are still able to read JSON, thanks to Prepare, so they can read during the mix. If this phase is rolled back, the data written by servers that briefly ran V3 is in JSON, and the data written by the other servers is in XML. Servers running V2 can read both, so this is not a problem.4.5 Backfilling: Before Removing the Old Reader
Even after the Activate phase, the ability to read XML data cannot be immediately removed. Data written before Prepare is still in XML. The XML reader is removed only after confirming that every object has been rewritten in JSON. The article refers to this rewriting process as "backfilling" and notes that it may require tools that operate in parallel while the service continues to read and write data.Figure 2 shows this flow and whether a rollback is safe at each phase.

4.6 When Two Phases Are Not Needed: Serializers That Keep Unknown Attributes
The article also gives rules of thumb for serialization (Stated, experience). Amazon generally avoids custom serialization formats and uses established formats such as JSON, Protocol Buffers, Cap’n Proto, and FlatBuffers. Amazon gives serializers a version separate from the source code and build, and stores that version with the data or in the metadata. It states:Typically, we design serializers to allow the presence of unknown attributes.
Where possible, Amazon's serializers also keep unknown attributes when they write data back. This ensures that even if a new version introduces new attributes, older versions will not discard those attributes when updating the same data. The article indicates that in such cases, a two-phase deployment is not necessary.
From this, whether to split into two phases depends on how the old version's readers handle what they do not know (Inference). If older versions can ignore unknown attributes and keep them, changes that add new attributes can be rolled back after a single deployment. Changes that make the whole data unreadable to the old version, such as compression or a format change, are split into two phases.
4.7 Relationship to Database Schema Changes
This article does not cover procedures that apply the same idea to database schema changes. Chapter 10 of the earlier article Zero-Downtime Database Change on RDS and Aurora covers the asymmetry between adding and removing columns and a two-stage deployment combined with the application.5. The Unit Each Deployment Mechanism Rolls Back
This chapter lists, for each AWS deployment mechanism, the unit its pages say a rollback returns and what they say remains.5.1 Lambda Aliases
A Lambda alias is an updatable pointer to a function version (Stated, specification).A Lambda alias is a pointer to a function version that you can update.
Weighted aliases distribute traffic between two versions of the same function (Stated, specification). You set this with
AdditionalVersionWeights, and the weighted alias page says that this allows you to test new versions with a small percentage of traffic and quickly revert if necessary. The unit rolled back is which version the alias points to and its weight. The alias pages say nothing about what a function version writes outside the function (Not stated). While weights are set, both versions are invoked at the same time, so the mix of versions described in Section 3.2 occurs (Inference).5.2 CodeDeploy
CodeDeploy redeploys a previously deployed revision as a new deployment (Section 2.3, Stated, specification). Automatic rollbacks will deploy the last successful revision if a deployment fails or if specified monitoring thresholds are reached. Manual rollbacks create a new deployment using a previously deployed revision.For EC2 and on-premises deployments, the CodeDeploy agent removes from the instance, during each deployment, the files that the most recent deployment installed. When files exist on the target that were not part of the previous deployment, you can choose how to handle them: fail the deployment, overwrite the existing files, or leave them as they are (Stated, specification). This is an example in which, for files outside the deployment unit, a kind of state, the page lets you choose whether they are returned.
5.3 ECS Deployment Circuit Breaker
The ECS deployment circuit breaker is available only for services that use the rolling update (ECS) deployment controller (Stated, specification). It provides the option to automatically roll back a failed deployment to the deployment that is in theCOMPLETED state (Stated, specification). If no COMPLETED deployment is found, the deployment will halt and no new tasks will be launched (Stated, specification). The unit of rollback is the service deployment, specifically the task definition and its configuration. The page says nothing about what the tasks write outside the service (Not stated).5.4 ECS Blue/Green Deployments
ECS blue/green deployments keep both blue and green running for the bake time after production traffic shifts. The page says the following about rollback (Stated, specification).Rollback: Blue/green deployments make it easier to roll back to the previous version if issues are detected, as the blue revision is kept running until the bake time expires.
During the bake time, traffic can be reverted to the running blue version (Inference). After the bake time has passed and the blue version is removed, rolling back will require another deployment (Inference). In either scenario, the state that green wrote during the bake time remains (Inference).
5.5 CloudFormation
As one way to handle a failed stack operation, CloudFormation can roll the stack back to its last known stable state (Stated, specification). Which operations roll back by default is left to Chapter 3 of the earlier article Express Mode and Pre-Deployment Validation in AWS CloudFormation. For the case where a rollback cannot complete, the page on continuing a rollback says the following (Stated, specification).Sometimes, when CloudFormation tries to roll back a stack update, it can't roll back all the changes it made during the update process. This is called the UPDATE_ROLLBACK_FAILED state.
The page's example is a rollback that fails while returning to a database instance that was deleted outside CloudFormation. While a stack in the
UPDATE_ROLLBACK_FAILED state cannot be updated, it can continue the rollback process to reach the UPDATE_ROLLBACK_COMPLETE state. The What's New post of October 22, 2026 announced force rollback, which completes the rollback in one operation even if some resources cannot roll back automatically, and says that any resource that still needs attention is recorded for review before the next deployment (Stated, What's New).CloudFormation rolls back the configuration of a stack's resources. None of the pages this article read says a rollback returns data within resources, such as items in a DynamoDB table or objects in an S3 bucket (Not stated). It is safest to assume that data within resources is not rolled back by a stack rollback (Inference).
5.6 RDS and Aurora Blue/Green Deployments
If the switchover of an RDS Blue/Green deployment stops partway, the changes are rolled back and neither environment keeps them (Stated, specification). However, as stated in Section 2.3, with PostgreSQL, rows written to the green environment during the switchover, after the application overrides the read-only setting, are not carried to blue (Stated, specification).Once the switchover is complete, the previous blue environment remains, but replication between the environments ceases (Stated, specification). The previous blue environment becomes read-only; for RDS for MySQL, it cannot be written to until restarted with
read_only set to 0; for RDS for PostgreSQL, it cannot be written to until restarted with default_transaction_read_only set to 0 (Stated, specification). For Aurora, the corresponding page states that even if the previous blue cluster is configured to allow writes, it will remain read-only until the Blue/Green deployment is deleted (Stated, specification). The user guides this article read describe no service operation that reverses a completed switchover (Not stated). An article on the AWS Database Blog (August 6, 2024) demonstrates how to manually configure logical replication from the new production environment back to the previous environment in Aurora MySQL (Stated, official blog).Details regarding the pre- and post-switchover processes are covered in Chapter 6 of the earlier article Zero-Downtime Database Change on RDS and Aurora.
5.7 Table 2: The Unit Each Deployment Mechanism Rolls Back
Table 2 summarizes Sections 5.1 through 5.6.| Mechanism | Unit Rolled Back | What the Pages Say Remains or Is Not Returned | Label |
|---|---|---|---|
| Lambda Alias | Version of the function the alias points to, and the weights from AdditionalVersionWeights. | No statement | Unit Rolled Back: Stated, Remaining: Not stated |
| CodeDeploy | The previous revision, redeployed as a new deployment with a new deployment ID | On EC2 and on-premises, you choose whether to fail, overwrite, or leave unchanged the files that were not part of the previous deployment. | Stated |
| ECS Circuit Breaker (rolling update deployment controller) | Deployments in the COMPLETED state. If none exist, the deployment stops. | No statement | Unit Rolled Back: Stated, Remaining: Not stated |
| ECS Blue/Green | Traffic is rolled back to the blue environment during the bake time. | No statement on what happens after the bake time | Stated and Inference |
| CloudFormation | The configuration of the stack's resources, back to the last stable state | Changes that cannot be rolled back result in an UPDATE_ROLLBACK_FAILED status. Force rollback records the resources that still need attention. Data within those resources is not stated. | Configuration: Stated, Data: Not stated |
| RDS and Aurora Blue/Green | In the event of a failure during the switchover, changes are rolled back. | In PostgreSQL, rows written to green during the switchover after the read-only setting was overridden are not in blue. After the switchover, replication stops, and the previous blue environment is set to read-only. | Stated |
No row says that a rollback returns the state that the new version wrote (Not stated).
6. What Both Versions Read, by Where State Is Kept
This chapter examines, for each location, how much of the state created by the new version remains, and whether it reaches the old version after a rollback.6.1 Database Rows and Columns
New columns added to the DB, and rows written in the new format, will remain even after an application rollback. None of the pages this article read says that an application deployment mechanism returns the DB schema or rows (Not stated). The rolled-back old version reads tables with the new columns and rows in the new format (Inference). The asymmetry between adding and removing columns, along with the two-stage deployment process, is discussed in Chapter 10 of the previously published Zero-Downtime Database Change on RDS and Aurora.6.2 SQS Queues and Dead-Letter Queues
SQS messages remain in the queue for the duration specified by theMessageRetentionPeriod. This value ranges from 60 seconds to 1,209,600 seconds (14 days), with a default of 345,600 seconds (4 days) (Stated, API reference). Messages sent by a newer version remain in the queue for the retention period, even after a rollback, and the old version receives them (Inference). Conversely, after a forward deployment, the new version receives messages that the old version sent. The deployment times of the sender and receiver, and how long the message has been in the queue, decide which version receives which message (Inference).Messages that have moved to the Dead-Letter Queue (DLQ) may remain there for an extended period. For standard queues, the time the message first entered the original queue sets its expiration, and this does not change when it is moved to the DLQ. For FIFO queues, the count starts again when the message moves to the DLQ (Stated, developer guide). Dead-letter queue redrive moves messages in the DLQ to another queue. The default destination is the original queue, and you can also choose another queue of the same type (Stated, developer guide). The version currently running will receive messages that have been redriven. A message that the new version wrote and that failed can be received by the old version after a rollback, and the reverse can also happen (Inference).
6.3 EventBridge Archives and Replay
EventBridge archiving allows you to store events and replay them to the original event bus at a later time. You can set how many days to keep events, and by default, EventBridge keeps them indefinitely (Stated, developer guide).By default, EventBridge stores events in an archive indefinitely.
The page gives an example of replaying past events in an application with new features, so that the events are processed again (Stated, developer guide). This represents a scenario where the current version reads events written by versions many generations back, the old writes, new reads direction. If events that the new version emitted are replayed after a rollback, the old version reads them, which is the new writes, old reads direction (Inference).
When it replays events, EventBridge adds a
replay-name field (Stated, developer guide). When you create an archive, a managed rule filters on whether this field is present so that replayed events are not sent back to the archive. If a receiver is configured to generate errors when encountering unknown fields, it's possible that only the replayed events will fail to be read (Inference). Section 4.6, regarding handling unknown attributes, is also relevant here.On event schemas, Chapter 6 of the earlier article AWS Messaging and Event Routing Decision Guide covers archives, replay, and schema registries. None of the pages this article read says whether EventBridge's schema registry checks compatibility when a new schema version is registered (Not stated).
6.4 Cache Values
ElastiCache's developer guide defines a Time-to-Live (TTL) as an integer value that specifies the number of seconds until a key expires. When an application attempts to read an expired key, it is treated as though the key does not exist (Stated, developer guide).Time to live (TTL) is an integer value that specifies the number of seconds until the key expires. Valkey or Redis OSS can specify seconds or milliseconds for this value. Memcached specifies this value in seconds. When an application attempts to read an expired key, it is treated as though the key is not found.
Values written to the cache in a new format by a newer version will persist until the TTL expires or the data is evicted (Inference). Older versions read these values. Values without a TTL have no expiration limit. When changing the format of cached values, take one of the following approaches (Inference):
- Store the version of the serializer along with the value, following the rule of thumb in Section 4.6. This allows older versions to treat values they don't recognize as cache misses.
- Include the format version in the key, allowing both older and newer versions to use separate keys.
- Divide the format changes into two phases as described in Chapter 4. In the Prepare phase, allow older versions to read the new format.
Clearing the cache during a rollback eliminates potential discrepancies, but an empty cache can place a significant load on downstream systems. The mechanisms by which an empty cache delays recovery are covered in Why a System Stays Down After the Cause Is Gone.
6.5 AWS Glue Schema Registry Compatibility Modes
AWS Glue Schema Registry determines whether a new version of a schema is accepted based on the rules defined by the compatibility mode (Stated, developer guide). There are eight compatibility modes available (Stated, API reference and developer guide).| Value | Summary of Developer Guide Description |
|---|---|
NONE | No compatibility checks are performed; all new versions are accepted. |
DISABLED | No new versions can be added to the schema. |
BACKWARD | Consumers can read both the current schema version and the previous schema version. Recommended. |
BACKWARD_ALL | Consumers can read both the current schema version and all previous schema versions. |
FORWARD | Consumers can read both the current schema version and the next schema version. |
FORWARD_ALL | Consumers can read data written using any newly registered schema version. |
FULL | Consumers can read data written using both the previous and next schema versions. |
FULL_ALL | Consumers can read data written using all previous schema versions. |
The description for
BACKWARD differs slightly in the API reference and developer guide, specifically in the way examples are presented. The developer guide describes it as follows (Stated, developer guide):BACKWARD: This compatibility choice is recommended because it allows consumers to read both the current and the previous schema version. You can use this choice to check compatibility against the previous schema version when you delete fields or add optional fields. A typical use case for BACKWARD is when your application has been created for the most recent schema.
The API reference describes the
Compatibility parameter of CreateSchema as follows (Stated, API reference).BACKWARD: This compatibility choice is recommended as it allows data receivers to read both the current and one previous schema version. This means that for instance, a new schema version cannot drop data fields or change the type of these fields, so they can't be read by readers using the previous version.
The first point, that it allows readers to use both the current and one previous schema version, is consistent across both documents. As for the examples, the developer guide says the mode can be used when you delete fields or add optional fields, while the API reference says a new schema version cannot drop fields. This article avoids taking a definitive stance and simply reproduces both statements with their respective sources.
Applied to the topic of this article, each compatibility mode can be read as protecting readers in one direction (Inference).
- The
BACKWARDmodes ensure that consumers of a new schema version can read data written using the previous schema version. This is the old writes, new reads direction, and it matches the order of switching readers first when rolling forward (Section 8.2). - The
FORWARDmodes ensure that consumers of a previous schema version can read data written using a new schema version. This is the new writes, old reads direction, which applies when a rolled-back consumer reads data in the new schema version left in the stream. - The
FULLmodes protect both directions. - Values with the suffix
_ALLperform checks against not just one previous schema version, but all previous schema versions. This is relevant for long-lived streams or archival playback scenarios where data written many generations back is read.
When operating with
BACKWARD alone, forward deployments are protected, but nothing checks that rolled-back consumers can read data in the new schema version (Inference). For consumers that expect rollbacks, the FULL modes are worth considering. The design of the stream's schema itself is left to Section 8.1 of the earlier article AWS Real-Time Streaming Data Pipeline Architecture Guide.6.6 Table 3: Reads and Writes by Where State Is Kept
Table 3 summarizes Sections 6.1 through 6.5. The values in the retention column come from the pages (Stated), and the direction columns are this article's own construction (Inference).| Location | How Long It Remains | When new writes, old reads occurs | When old writes, new reads occurs |
|---|---|---|---|
| Database Rows and Columns | Until deletion | After a rollback, older versions read new columns and new row formats. | Newer versions read rows written by older versions. |
| SQS Queue | MessageRetentionPeriod (60 seconds to 14 days, default 4 days) | After a rollback, older versions receive messages sent by newer versions. | After moving forward, newer versions receive messages sent by older versions. |
| SQS Dead-Letter Queue (DLQ) | Calculated from the original timestamp for standard queues; calculated from the moved timestamp for FIFO queues. | After a rollback, older versions receive messages that were redriven. | After moving forward, newer versions receive messages that were redriven. |
| EventBridge Archive | Indefinitely by default. | After a rollback, older versions read replayed events. | Current versions read events written by versions many generations prior, through replay. |
| Cache Values | Until the Time-To-Live (TTL) expires; otherwise, no limit. | After a rollback, older versions read values in the new format. | After moving forward, newer versions read values in the old format. |
| Glue Schema Registry | While the schema versions stay registered | The direction that the FORWARD modes protect. | The direction that the BACKWARD modes protect. |
7. When to Roll Forward and When to Split a Change That Cannot Be Rolled Back
This chapter discusses situations where it's preferable not to roll back, and how to build a change before that decision.7.1 The OPS04-BP02 Recommendation
OPS04-BP02 Automate testing and rollback, in the consolidated version of the Well-Architected Framework, says the following (Stated, recommendation).Not every failure calls for rollback. Rolling forward with a fix can be safer, especially when a change has altered persistent state that rollback cannot cleanly reverse.
This recommendation suggests that not every failure necessitates a rollback, and that in some cases, it may be safer to apply a fix and proceed forward, particularly when a change has modified persistent data that cannot be easily reverted. The page goes on to say that you should decide which path to take, rollback or roll forward, and the conditions that start each, and that you should run and test either choice. This is a recommendation, and it does not ask you to choose roll forward for every change.
The same page also recommends (Stated, recommendation) using feature flags to gradually release features and to enable the ability to disable features without requiring a redeployment. Even when a feature flag is disabled, the state created while that feature was active remains (Inference). Whether older code paths can still read this new state after disabling the feature is the same question as with a rollback.
7.2 DL.ADS.2 in DevOps Guidance
DevOps Guidance [DL.ADS.2] Implement automatic rollbacks for failed deployments says that rollback procedures should include redeploying the last successful code revision, artifact version, or container image (Stated, recommendation). Because the cause of a problem is not always the most recent deployment, it also recommends being able to choose and return to a specific earlier release. In cases where the problem appears to be environment-specific, it also lists the option of waiting for a new release with the fix to move through the pipeline. The related resources on this page include "Ensuring rollback safety during deployments" from the Builders' Library.The more freely you can choose an earlier release to return to, the older the target version can be. If reverting to a version several generations back, that version must read the state written by every later version (Inference). This presents a similar challenge to Glue Schema Registry's compatibility mode with the
_ALL suffix, which inspects all previous schema versions.7.3 Identifying Changes That Cannot Be Rolled Back, and Splitting Them
The Builders' Library article concludes that when a change turns out not to be safe to roll back, it can typically be divided into two changes, each safe to roll forward and back (Stated, experience). Based on the chapters so far, this article summarizes the items to verify before deployment as follows (Inference).- Does the change alter how state is written? If not, a rollback causes no misreads.
- If it does, can the older version read the new format? If the change only adds attributes, and the older version allows unknown attributes and keeps them when it writes the data back (Section 4.6), then it can be reverted without splitting into two deployments.
- If the older version cannot read the new format, split the changes into two deployments: Prepare, which adds the new reading capability, and Activate, which changes how data is written (Chapter 4).
- Ensure that Prepare has reached all readers before activating. If readers span multiple services, verify across all services.
- Include a bake period between Prepare and Activate. The Well-Architected Framework's REL08-BP05 also lists running follow-on deployments without bake time as an anti-pattern (Stated, recommendation).
- Remove the old reader after Activate only once backfilling has left no data in the old format.
- Verify that the duration for which the new state persists (Table 3 in Chapter 6) is not longer than the bake period. SQS retention periods, DLQs, archives, and caches without TTLs may retain data in both the old and new formats even after the bake period.
- If the change still cannot be rolled back, determine the conditions under which to choose roll forward instead of rollback, before deploying (Section 7.1).
8. Verifying Rollback in Testing
This chapter covers upgrade-downgrade testing, as described in Builders' Library, and the recommendations in OPS04-BP02.8.1 Upgrade-Downgrade Testing
The Builders' Library article says Amazon explicitly verifies that a change is safe to roll forward and back with what it calls upgrade-downgrade testing (Stated, experience). The testing environment should closely resemble the production environment, using request volumes as close as possible to those in production, and exercising all APIs continuously. The environment is then taken through three stages. Each stage lasts long enough for all APIs, backend workflows, and batch jobs to run at least once.- Deploy the change to about half of the fleet, creating a state where two versions are running concurrently.
- Complete the deployment.
- Initiate a rollback deployment, following the same procedure until all servers are running the older version.
If no errors or unexpected behavior occur during these three stages, Amazon considers the test successful. The third stage is the one that exercises new writes, old reads from Section 3.4 (Inference).
8.2 The Order of Readers and Writers
When making changes that span multiple microservices, maintain the same deployment order in both testing and production environments. However, the order may differ when moving forward versus rolling back. The article says the following about serialization (Stated, experience).That is, readers go before writers while rolling forward whereas writers go before readers while rolling backward.
When moving forward, you update readers first. When rolling back, you revert writers first. When readers go first during a forward movement, all readers will be able to read the new data format before any new data of that format is written. When writers go first during a rollback, writing in the new format stops before readers are rolled back (Inference). Even so, any new data written in the new format before the reversion will remain, so check that the rolled-back readers do not read it for as long as it remains (Chapter 6) (Inference).
8.3 Test Environments to Avoid
The article names two test environments to avoid (Stated, experience). The first is an environment where each service runs on a single server. In this setup, deployments are entirely atomic, preventing two versions from running concurrently. The article suggests that, similar to a production environment, test environments should also place multiple servers across several Availability Zones behind each service. The second environment to avoid is one that deploys to all servers at once to speed up testing. This, too, prevents two versions from running at the same time, and in that setup a problem when rolling forward was missed. The article says Amazon uses the same deployment configuration in all test and production environments.In the context of AWS components, this means avoiding configurations such as switching Lambda aliases without weighting, running a single task for ECS services, or using CodeDeploy to deploy configurations to all instances simultaneously, all of which remove the mix of two versions from the test (Inference).
8.4 OPS04-BP02: A Rollback Not Yet Run Is Unproven
OPS04-BP02 says the following about rollback (Stated, recommendation).A rollback that has not run recently is unproven — treat it as a risk and flag it to stakeholders until you have practiced it.
The page goes on to say that you should run roll-forward, rollback, and roll-forward again to verify that every path recovers (Stated, recommendation). REL08-BP05 in the same consolidated version lists, as a benefit of automated deployment, that automatic rollback returns the workload to its last working state when a production issue appears (Stated, recommendation). In what this article read, nothing says that this state includes DB rows or queue messages written by the new version (Not stated). This article reads it as a mechanism that returns the deployment unit and checks the remaining state separately in Chapter 6 (Inference).
9. Frequently Asked Questions About Rollback Safety
Q1. If there's a rollback mechanism, does it revert to the state before deployment?In the pages this article read, what returns is the deployment unit. A Lambda alias returns the pointer to a function version, CodeDeploy the revision, ECS the deployment, and CloudFormation the stack configuration. No page says a rollback returns the DB rows, queue messages, archived events, or cache values that the new version wrote. The pages on Blue/Green deployments using logical replication in RDS for PostgreSQL and on Aurora PostgreSQL say that rows the application writes to green during the switchover after overriding the read-only setting are not in blue if the switchover rolls back.
Q2. Does CodeDeploy's rollback feature restore the previous deployment?
No. CodeDeploy redeploys the previously deployed revision as a new deployment with a new deployment ID. For EC2 and on-premises deployments, if files that were not part of the previous deployment are present at the destination, you can choose to fail the deployment, overwrite those files, or leave them as they are.
Q3. Is Two-Phase Deployment an AWS service feature?
No. It is Amazon's experience, written in a Builders' Library article: a method that splits a change into two deployments, Prepare, which adds a way to read, and Activate, which changes how data is written. It can be used with any deployment mechanism. Each phase can be rolled back individually, but not both together, so a bake period goes between them.
Q4. If Glue Schema Registry is set to
BACKWARD, is the rollback safe?That alone may not be sufficient. The developer guide explains that
BACKWARD ensures consumers can read both the current schema version and the immediately preceding schema version. Consumers using the older, rolled-back version will attempt to read data from the remaining, newer schema versions, which is the direction that the FORWARD modes protect (Inference). The FULL modes protect both directions.Q5. Are ECS's bake time and Builders' Library's bake period the same thing?
No. In ECS, bake time refers to the period after live traffic is shifted in a blue/green deployment, during which both the blue and green environments are running. This allows for easy rollback during that time. In Builders' Library, a bake period is the time allocated between the Prepare and Activate phases of a two-phase deployment. The article says it is usually a few days.
Q6. What do you do if you deploy a change that cannot be rolled back?
The Well-Architected Framework's OPS04-BP02 recommends that when a change has altered persistent state that rollback cannot cleanly reverse, it may be safer to apply a fix and move forward. It says to decide in advance which path to take and the conditions that start each, and to run and test either one.
Q7. What do you verify during upgrade-downgrade testing?
An article in the Builders' Library describes taking an environment that closely resembles production through three stages: deploying the change to about half of the fleet, completing the deployment, and then rolling back so that all servers run the previous version. Each stage lasts long enough for all APIs, workflows, and batch jobs to run at least once. This testing is not feasible in environments with only one server, or in environments where all servers are updated simultaneously, as it is not possible to have both versions running concurrently.
10. Summary
Rollbacks revert the unit of deployment, but the state of data written by a new version may persist. This article sorted deployment mechanisms and the places where state is kept as follows:| Layer | What is Rolled Back | What May Persist | Verification Steps |
|---|---|---|---|
| Deployment Mechanism (Lambda, CodeDeploy, ECS, CloudFormation) | The pointer to a function version, the revision, the deployment, the stack configuration | Data written outside the mechanism. In EC2 and on-premises CodeDeploy, files not part of the previous deployment. | Which version reads what during the mix and after the rollback |
| Database (RDS, Aurora) | If the switchover fails partway, the changes roll back | New columns and rows. In PostgreSQL, rows written to green during the switchover after the read-only setting was overridden | The procedures in the earlier DB article |
| Messages and Events (SQS, DLQ, EventBridge Archives) | No statement | Messages within the retention period, events within indefinite archives. | Whether the old version reads the new format, and the new version the old format |
| Cache Values | No statement | Values that persist until their TTL expires. | The version of the value format, how keys are split, and the TTL |
| Schema Registry (Glue) | No statement | Versions of registered schemas. | Which direction's readers the compatibility mode protects |
- The Builders' Library article says that the new version must read data written by the old version, and vice versa. After a rollback, the old version reads what the new version wrote.
- Changes that modify both reading and writing processes should be split into two deployments: Prepare and Activate. Each phase can be rolled back individually, but not both together. A bake period goes between them, and the old reader is removed after backfilling.
- With a serializer that allows and keeps unknown attributes, changes that add attributes can be rolled back without splitting them into two phases.
- The Builders' Library reflects Amazon's experience. The Well-Architected Framework and DevOps Guidance reflect AWS recommendations. Developer guides and API references reflect component specifications.
- Rollback safety is verified with a test that runs both versions at the same time and finally runs the rollback. OPS04-BP02 recommends treating a rollback that has not run recently as unproven.
- This article is based on documents read on December 3, 2026, during the re:Invent 2026 conference. The pages may change.
11. References
- Ensuring rollback safety during deployments - AWS Builder Center
- OPS04-BP02 Automate testing and rollback - AWS Well-Architected Framework
- REL08-BP04 Deploy using immutable infrastructure - AWS Well-Architected Framework
- REL08-BP05 Deploy changes with automation - AWS Well-Architected Framework
- Release notes - AWS Well-Architected Framework
- DL.ADS.2 Implement automatic rollbacks for failed deployments - DevOps Guidance
- Create an alias for a Lambda Event Function - AWS Lambda
- Implement Lambda canary deployments using a weighted alias - AWS Lambda
- Redeploy and roll back a deployment with CodeDeploy - AWS CodeDeploy
- How the Amazon ECS deployment circuit breaker detects failures - Amazon Elastic Container Service
- Amazon ECS blue/green deployments - Amazon Elastic Container Service
- Continue rolling back an update - AWS CloudFormation
- Choose how to handle failures when provisioning resources - AWS CloudFormation
- AWS CloudFormation now simplifies stack update rollback operations - AWS What's New
- Switching a blue/green deployment in Amazon RDS - Amazon Relational Database Service
- Switching a blue/green deployment in Amazon Aurora - Amazon Aurora
- Implement a rollback strategy after an Amazon Aurora MySQL blue/green deployment switchover - AWS Database Blog
- SetQueueAttributes - Amazon Simple Queue Service
- Using dead-letter queues in Amazon SQS - Amazon Simple Queue Service
- Learn how to configure a dead-letter queue redrive in Amazon SQS - Amazon Simple Queue Service
- Archiving and replaying events in Amazon EventBridge - Amazon EventBridge
- Caching strategies for Memcached - Amazon ElastiCache
- Schema registries in Amazon EventBridge - Amazon EventBridge
- AWS Glue Schema registry - AWS Glue
- CreateSchema - AWS Glue
- Zero-Downtime Database Change on RDS and Aurora - Blue/Green Deployments, Upgrades, and Rollback Design
- What an Agent Release Contains on AgentCore - Runtime Versions, Endpoints, and Parts Outside the Version
- Safe Foundation Model Rollout Strategies on AWS - Canary Traffic Shifting, Evaluation Gates, and Automated Rollback
- Amazon ECS Deployment Lifecycle - Early Success Criteria, Deferred Cleanup, and Managed Daemon Rollouts
- AWS Real-Time Streaming Data Pipeline Architecture Guide - Ingestion, Processing, and Delivery with Kinesis, Managed Service for Apache Flink, and OpenSearch
- AWS Messaging and Event Routing Decision Guide - Choosing Between SQS, SNS, EventBridge, and Kinesis
- Express Mode and Pre-Deployment Validation in AWS CloudFormation - What Completion Stopped Meaning, What Rollback Now Defaults To, and Which Checks Silently Skip
- Cell-Based Architecture and Shuffle Sharding on AWS - Blast Radius Reduction Patterns for Large-Scale Workloads
- Why a System Stays Down After the Cause Is Gone - Cold Caches, Queue Backlogs, and Fallbacks on AWS
References:
Tech Blog with curated related content
Written by Hidekazu Konishi