Database / Google Spanner Database Interview questions
How does Spanner implement point-in-time recovery internally?
Point-in-time recovery (PITR) relies on Spanner's version_retention_period, a per-database setting (up to 7 days) that controls how long old row versions are kept before garbage collection instead of being purged immediately after being superseded.
ALTER DATABASE orders_db SET OPTIONS (version_retention_period = '7d');
Internally, every write in Spanner is already timestamped by TrueTime and stored as a new version rather than an in-place overwrite, since Spanner is a multi-version system that needs historical versions anyway to serve stale reads. Extending the retention window simply keeps those historical versions around longer. A stale read or read-only transaction can then specify an exact past timestamp within that window, and Spanner reconstructs the database (or a specific table) as it existed at that instant by reading the appropriate row versions from each split, effectively giving a consistent snapshot without restoring from a separate backup file. This is why PITR in Spanner is fast to initiate compared to restoring a traditional backup - it reuses existing multi-version storage rather than replaying a backup image - but it is bounded by the retention window, so anything older requires a full backup restore instead.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
