Raft Log Persistence for Faster Asynchronous Transaction Replication
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing Raft-based asynchronous database replication systems face challenges in maintaining optimal performance due to variations in follower processing speeds, inefficient IO instruction timing for durability, and memory management issues with long column names, leading to increased user transaction response times and failover delays.
Innovation Solution
Implement flow control mechanisms to manage follower speed differences, optimize Raft log persistence, and compress column names using hashing, while consolidating heartbeats and maintaining apply processes during failovers to enhance replication efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the leader sends separate post-commit LCR streams to all followers, then transaction consensus can be communicated to followers, but this violates the single Raft log stream assumption and increases system complexity
Solution Approach 1:
The patent merges the post-commit LCR transmission into the existing Raft log stream by having the leader append post-commit LCRs to the same log that contains pre-commit LCRs. This eliminates the need for separate post-commit LCR streams while maintaining the ability to communicate transaction consensus to all followers, thereby reducing system complexity without sacrificing reliability
2Reliability
If the leader waits for post-commit LCR transmission to all followers before committing a transaction, then consensus is ensured, but user transaction response time increases due to CPU contention, memory pressure, or network hiccups
Solution Approach 1:
The patent applies preliminary action by having followers apply pre-commit LCRs to their local Raft logs immediately upon receipt, before the leader has finished transmitting post-commit LCRs to all followers. This allows followers to prepare for transaction commitment in advance, reducing the time the leader needs to wait and thereby decreasing user transaction response time while still ensuring consensus through the subsequent post-commit LCR transmission
3Reliability
If the leader uses a default Raft heartbeat interval of 500ms, then leader election can be triggered after 6 missed heartbeats (3 seconds), but this causes unnecessary leader ping-pong during small network hiccups
Solution Approach 1:
The patent implements dynamic heartbeat interval adjustment where the leader modifies the heartbeat interval based on current system conditions. When network hiccups are detected or replication lag is observed, the leader extends the heartbeat interval to reduce unnecessary ping-pong elections. This dynamic adjustment maintains reliable leader election while improving system stability during transient network issues
4Productivity
If followers detach slower followers from the in-memory queue when lag increases, then faster followers can process LCRs without throttling, but slower followers must read from persistent storage which increases their lag further
Solution Approach 1:
The patent implements feedback mechanisms where followers continuously monitor their replication lag and provide this information back to the leader. The leader uses this feedback to make informed decisions about flow control, deciding when to throttle or detach followers based on real-time lag conditions. This feedback loop allows the system to optimize replication processing speed while minimizing the negative impact of follower lag through coordinated management
5Productivity
If the LCR persister waits with a timeout before issuing IO write or flush, then immediate IO may be inefficient when additional pending commit LCRs exist, but this results in time loss when no pending commit records are available
Solution Approach 1:
The patent applies preliminary action by having the LCR persister buffer LCRs in memory and only issue IO operations when necessary, such as when the buffer is full or when durability is explicitly required. This allows the system to batch IO operations and avoid unnecessary immediate writes, improving IO efficiency while maintaining durability through targeted asynchronous flushing at appropriate moments
Data Source
AI summary
Replication is improved in a globally distributed database, such as a replicated sharded database, which uses raft-based asynchronous database replication. Improvements include Raft log persistence, coordination of followers' processing speed, transaction outcome determination, and column name compression, and improved failover time through heartbeat consolidation and keeping apply processes of followers running across failovers.


