Database Read Routing via State Machine for Consistency
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The existing infrastructure for global databases and their clones experiences inconsistencies due to asynchronous updates, leading to potential side effects like 'undeleting' virtual machines, as reads from the global database and its clone may produce different results over time.
Innovation Solution
Implementing a state machine in each region to manage the state of projects, redirecting read requests to the global database at a specific timestamp when the clone is not up-to-date, and serving requests from the global clone once it is synchronized.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If data is replicated asynchronously from global database to global clone database, then replication speed is improved, but data consistency between global database and global clone database deteriorates
Solution Approach 1:
The system performs preliminary actions by recording the timestamp when the global clone database enters the pending state, and uses this timestamp to redirect read requests to the global database at the specific time point, ensuring data consistency before replication completes
Solution Approach 2:
A state machine is introduced as an intermediary component that tracks the replication state (ready or pending) and mediates read requests by redirecting them appropriately based on the current state, preventing inconsistent reads during asynchronous replication
2Productivity
If read requests are served from global clone database, then read performance is improved, but risk of reading past version data increases
Solution Approach 1:
The state machine provides feedback about the replication status (ready or pending state) to the read request handling logic, enabling dynamic routing decisions that prevent reading past version data while maintaining high read performance when safe
Solution Approach 2:
The system preliminarily determines the replication state and records timestamps before serving read requests, using this pre-computed information to redirect requests to the correct data source at the correct time point, avoiding the need to check consistency at request time
Data Source
AI summary
The present disclosure provides for consistent reads in a global database that is replicated to one or more global clones. A state machine is implemented, and executed independently, for each project in each region. Based on the state of a project when a read request is received, the read request will be served by the global database, served by the global clone, or ignored as an invalid request.


