DynamoDB PITR schema rollback missing automatic merge for post-restore writes
0 reputation · 12 Sept 2023, 23:47 UTC
0 reputation · 12 Sept 2023, 23:47 UTC
DynamoDB Point-in-time recovery (PITR) restores a table to any second within the last 35 days, including the schema that existed at that timestamp. When a schema change such as adding or removing a Global Secondary Index is rolled back by restoring to an earlier point, the restored table reflects the previous schema, but all writes made after the restore timestamp are absent. The service does not provide an automatic rollback API, and it does not merge post-restore writes into the recovered schema, forcing a choice between reverting the schema and losing recent data.
Because restoring a large table can take minutes to hours and leaves the original table unavailable unless a temporary copy and swap strategy is used, teams need a predictable way to reconcile the restored schema with newer writes. Restored GSIs may also carry a backlog of pending index updates, which can throttle writes if traffic resumes immediately.
What is the recommended operational pattern for reverting a DynamoDB schema change with PITR while preserving writes that occurred after the restore point? Is there a supported mechanism to replay or merge those writes into the restored table without manual application logic? How should teams handle the GSI update backlog and throttling risk when swapping a restored table back into production?
33775 reputation · 13 Sept 2023, 09:12 UTC
There is no native AWS mechanism to automatically merge post-restore writes into a table recovered via Point-in-Time Recovery (PITR). Because PITR creates a entirely new table rather than performing an in-place rollback, any data written to the original table after the chosen restore timestamp is not captured in the restored instance.
To revert a schema change while preserving recent writes, you must implement a Stream-based Replay pattern. This requires DynamoDB Streams to be enabled on the source table before the restore process begins.
Table_Restored) at the desired timestamp.Table_Restored.When a table is restored, Global Secondary Indexes (GSIs) are backfilled asynchronously. If you route production traffic to the restored table before this process completes, you risk severe write throttling because the backfill process consumes provisioned throughput.
PendingReplicationCount metric in Amazon CloudWatch for every GSI on the restored table.PendingReplicationCount reaches zero for all indexes.This pattern assumes the use of a Last-Writer-Wins conflict resolution strategy during the stream replay. If your application requires complex versioning, the replay logic must be modified to check item timestamps before applying PutItem or UpdateItem calls to avoid overwriting newer data with older state.
Diagnostic Requirement: Are you using On-Demand capacity or Provisioned capacity? If using Provisioned, the risk of throttling during GSI backfill is significantly higher and requires manual scaling before the swap.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.