move trait method: from RaftLogStorage
to RaftLogReader::read_vote()
#1077
Labels
A-log
Area: raft log storage
A-replication
Area: replication protocol
good first issue
Good for newcomers
To Ensuring Consecutive Raft Log Replication
Problem Description
In a Raft-based system, there is no guarantee that sequential read-log operations, such as
read log[i]
andread log[i+1]
, will yield consecutive log entries. The reason for this is that Raft logs can be truncated, which disrupts the continuity of the log sequence. Consider the following scenario:log[4]
.log[5]
.Now, the read operation for
log[5]
becomes invalid because the log at index 6, term 5 (6-5
) is no longer a direct successor to the log at index 4, term 4 (4-4
). This violates Raft's log continuity requirement for replication.To illustrate:
Proposed Solution
To ensure consecutive log entries for safe replication, it is necessary to verify that the term has not changed between log reads. The following updated operations are proposed:
read vote
(returnsv1
)read log[i]
read log[i+1]
read vote
(returnsv2
)If
v1
is equal tov2
, we can confidently say thatlog[i]
andlog[i+1]
are consecutive and the replication is safe. Therefore,ReplicationCore
must check the term (vote) as part of its replication process to ensure log consecutivity.Conclusion
The current release mitigates this issue by immediately halting communication with
ReplicationCore
to prevent any new replication commands from being processed. However, future iterations ofReplicationCore
may operate more proactively. To maintain the integrity of replication,ReplicationCore
will be required to independently ensure the consecutivity of logs before proceeding. This is an important consideration for the ongoing development of the system.TODO
Because
RaftLogStorage
implementsRaftLogReader
,read_vote()
should be move fromRaftLogStorage
toRaftLogReader
.The text was updated successfully, but these errors were encountered: