krishvishal commented on code in PR #2546:
URL: https://github.com/apache/iggy/pull/2546#discussion_r2678799753
##########
core/common/src/types/consensus/header.rs:
##########
@@ -389,3 +397,200 @@ impl ConsensusHeader for ReplyHeader {
self.size
}
}
+
+/// StartViewChange message header.
+///
+/// Sent by a replica when it suspects the primary has failed.
+/// This is a header-only message with no body.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(C)]
+pub struct StartViewChangeHeader {
+ pub checksum: u128,
+ pub checksum_padding: u128,
+ pub checksum_body: u128,
+ pub checksum_body_padding: u128,
+ pub nonce_reserved: u128,
+ pub cluster: u128,
+ pub size: u32,
+ pub epoch: u32,
+ pub view: u32,
+ pub release: u32,
+ pub protocol: u16,
+ pub command: Command2,
+ pub replica: u8,
+ pub reserved_frame: [u8; 12],
+
+ pub reserved: [u8; 128],
+}
+
+unsafe impl Pod for StartViewChangeHeader {}
+unsafe impl Zeroable for StartViewChangeHeader {}
+
+impl ConsensusHeader for StartViewChangeHeader {
+ const COMMAND: Command2 = Command2::StartViewChange;
+
+ fn validate(&self) -> Result<(), ConsensusError> {
+ if self.command != Command2::StartViewChange {
+ return Err(ConsensusError::InvalidCommand {
+ expected: Command2::StartViewChange,
+ found: self.command,
+ });
+ }
+
+ if self.release != 0 {
+ return Err(ConsensusError::InvalidField("release !=
0".to_string()));
+ }
+ Ok(())
+ }
+
+ fn size(&self) -> u32 {
+ self.size
+ }
+}
+
+/// DoViewChange message header.
+///
+/// Sent by replicas to the primary candidate after collecting a quorum of
+/// StartViewChange messages.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(C)]
+pub struct DoViewChangeHeader {
+ pub checksum: u128,
+ pub checksum_padding: u128,
+ pub checksum_body: u128,
+ pub checksum_body_padding: u128,
+ pub nonce_reserved: u128,
+ pub cluster: u128,
+ pub size: u32,
+ pub epoch: u32,
+ pub view: u32,
+ pub release: u32,
+ pub protocol: u16,
+ pub command: Command2,
+ pub replica: u8,
+ pub reserved_frame: [u8; 12],
+
+ /// The highest op-number in this replica's log.
+ /// Used to select the most complete log when log_view values are equal.
+ pub op: u64,
+
+ /// The replica's commit number (highest committed op).
+ /// The new primary sets its commit to max(commit) across all DVCs.
+ pub commit: u64,
+
+ /// The view number when this replica's status was last normal.
+ /// This is the key field for log selection: the replica with the
+ /// highest log_view has the most authoritative log.
+ pub log_view: u32,
Review Comment:
From my understanding of VSR-revisited paper, `log_view` is essential for
correctness of consensus. Its called `v'` in the paper. Its used for correct
log selection during view changes. The paper states: "selects as the new log
the one contained in the message with the largest `v'`". Without it, we cannot
correctly determine which replica's log is authoritative, which can lead to
loss of committed operations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]