From 5b140f78add6ae0b0272b0cdc5617fc63ef3bb84 Mon Sep 17 00:00:00 2001 From: Pavel Kalinnikov Date: Wed, 12 Jun 2024 13:00:09 +0100 Subject: [PATCH] testdata: add test for dropping conf change This commit adds a test which ensures a config change is not proposed if the leader has another yet unapplied config change. Ported from https://github.com/cockroachdb/cockroach/pull/124804 --- testdata/confchange_drop_if_unapplied.txt | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 testdata/confchange_drop_if_unapplied.txt diff --git a/testdata/confchange_drop_if_unapplied.txt b/testdata/confchange_drop_if_unapplied.txt new file mode 100644 index 00000000..83f4f97f --- /dev/null +++ b/testdata/confchange_drop_if_unapplied.txt @@ -0,0 +1,59 @@ +# This test verifies that a config change is not proposed if the leader has +# unapplied config changes. This ensures a safety requirement stated in +# https://github.com/etcd-io/etcd/issues/7625#issuecomment-489232411 + +# The check should be performed even if conf change validation is disabled. +add-nodes 1 voters=(1) index=2 disable-conf-change-validation=true +---- +INFO 1 switched to configuration voters=(1) +INFO 1 became follower at term 0 +INFO newRaft 1 [peers: [1], term: 0, commit: 2, applied: 2, lastindex: 2, lastterm: 1] + +campaign 1 +---- +INFO 1 is starting a new election at term 0 +INFO 1 became candidate at term 1 + +stabilize log-level=none +---- +ok + +# Propose one config change. It should be accepted. +propose-conf-change 1 transition=explicit +l2 l3 +---- +ok + +# The first config change gets appended. +process-ready 1 +---- +Ready MustSync=true: +Entries: +1/4 EntryConfChangeV2 l2 l3 + +# Propose another config change. It should be rejected, because the first config +# change hasn't applied on the leader yet. +propose-conf-change 1 +l4 +---- +INFO 1 ignoring conf change {ConfChangeTransitionAuto [{ConfChangeAddLearnerNode 4}] []} at config voters=(1): possible unapplied conf change at index 4 (applied to 3) + +# The new config change is appended to the log as an empty entry. +stabilize 1 +---- +> 1 handling Ready + Ready MustSync=true: + HardState Term:1 Vote:1 Commit:4 + Entries: + 1/5 EntryNormal "" + CommittedEntries: + 1/4 EntryConfChangeV2 l2 l3 + INFO 1 switched to configuration voters=(1)&&(1) learners=(2 3) +> 1 handling Ready + Ready MustSync=false: + HardState Term:1 Vote:1 Commit:5 + CommittedEntries: + 1/5 EntryNormal "" + Messages: + 1->2 MsgApp Term:1 Log:1/4 Commit:4 Entries:[1/5 EntryNormal ""] + 1->3 MsgApp Term:1 Log:1/4 Commit:4 Entries:[1/5 EntryNormal ""]