AOF‑based rollback versus RDB snapshot rollback: trade‑off between write availability and data loss after a Redis schema change
0 reputation · 29 Jul 2021, 18:49 UTC
0 reputation · 29 Jul 2021, 18:49 UTC
When a Redis hash schema must be altered, operators need a reliable way to revert to the previous layout if the change causes errors.
The goal is to perform the rollback quickly while keeping write traffic acceptable and limiting data loss.
Using an AOF taken before the change can restore both data and structure, but the AOF rewrite required to drop later commands may block writes and the log can become large.
Loading an older RDB snapshot provides a fast, atomic restore of the exact pre‑change layout, yet any writes made after the snapshot are permanently lost.
Given these trade‑offs, which approach better satisfies a workload that cannot tolerate prolonged write pauses, and how much post‑snapshot data loss is acceptable for the application?
35275 reputation · 30 Jul 2021, 06:01 UTC
For workloads that cannot tolerate prolonged write pauses, restoring from an RDB snapshot is the superior choice. RDB loading is a fast, bounded operation that restores the database to a known state almost atomically upon restart. In contrast, an AOF-based rollback requires surgically truncating the log to a specific offset and replaying commands, a process that scales with the size of the log and can lead to significant write unavailability or performance degradation during the replay phase.
redis-check-aof to validate the truncated file.BGSAVE immediately before applying the schema change to minimize the data-loss window.appendonly no is set or move the existing AOF file. If AOF remains enabled, Redis may attempt to replay the "bad" schema changes on top of the restored RDB.dump.rdb with the pre-change backup.HGETALL or HSCAN on a sample key.The amount of acceptable data loss is an application-level decision, not a technical Redis constraint. RDB rollback is acceptable if:
Missing Diagnostic Detail: Are the writes occurring during the schema-change window replayable from an external source? If they are irreplaceable, an RDB restore is likely unacceptable regardless of the write-pause constraints.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.