hubcio commented on code in PR #4485:
URL: https://github.com/apache/iggy/pull/4485#discussion_r4358572476
##########
core/consensus/src/impls.rs:
##########
@@ -8173,6 +8173,336 @@ mod probe_answer_tests {
}
}
+#[cfg(test)]
+mod recovery_election_tests {
+ //! The probe-exhaustion election of a restarted replica.
+ //!
+ //! A replica that restarts probes for the current view and, when nobody
+ //! answers, elects on its recovered log as though the whole cluster had
+ //! restarted. Under `replicated` durability that log can be shorter than
what
+ //! the replica acked before the crash, so the fallback is safe only when
the
+ //! quorum it elects with still holds every committed op.
+
+ use super::*;
+ use crate::LocalPipeline;
+ use crate::dvc_merge::suffix_all_present;
+ use crate::test_bus::NoopBus;
+ use crate::view_change_quorum::encode_prepare_headers;
+ use iggy_binary_protocol::{HEADER_SIZE, Operation};
+
+ const REPLICA_COUNT: u8 = 3;
+ /// Primary of `OLD_VIEW`, crashed holding only part of what it committed.
+ const RESTARTED_PRIMARY: u8 = 0;
+ /// Crashed earlier, behind the committed tail.
+ const LAGGING_BACKUP: u8 = 1;
+ /// The only replica that never crashed, and the only one holding the tail.
+ const SURVIVOR: u8 = 2;
+ const OLD_VIEW: u32 = 3;
+ /// `RESTARTED_PRIMARY` committed through here with `SURVIVOR`'s acks.
+ const COMMITTED: u64 = 10;
+ /// What `RESTARTED_PRIMARY`'s WAL held at the crash: its own appends of
+ /// `RECOVERED_HEAD + 1..=COMMITTED` were queued but not yet written, which
+ /// `replicated` durability acknowledges.
+ const RECOVERED_HEAD: u64 = 7;
+ /// `LAGGING_BACKUP` crashed before the tail was prepared.
+ const LAGGING_HEAD: u64 = 5;
+ /// Enough for several probe exhaustions and status escalations.
+ const TICKS: u64 =
+ 4 * TimeoutManager::REQUEST_START_VIEW_MESSAGE_TICKS *
PROBE_ATTEMPTS_MAX as u64;
+
+ fn group() -> u64 {
+ IggyNamespace::new(0, 0, 0).inner()
+ }
+
+ /// Op `op` of the log every replica shares up to its own head,
hash-chained
+ /// from op 1 so the merge accepts it.
+ fn prepare(op: u64) -> PrepareHeader {
+ let mut parent = 0;
+ let mut header = PrepareHeader::default();
+ for at in 1..=op {
+ header = PrepareHeader {
+ command: Command::Prepare,
+ operation: Operation::SendMessages,
+ op: at,
+ view: OLD_VIEW,
+ parent,
+ commit: at - 1,
+ timestamp: at,
+ ..Default::default()
Review Comment:
warning: the prepares use cluster `0`, but replicas use cluster `1`, so
backups reject `StartView`. set each prepare's cluster to the replicas' cluster
before the checksum calculation.
--
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]