Skip to content

test: fix flaky test_consensus_snapshot_create_collection voter race - #8951

Merged
generall merged 1 commit into
devfrom
fix/consensus-snapshot-create-collection-flaky-voter-race
May 7, 2026
Merged

generall merged 1 commit into
devfrom
fix/consensus-snapshot-create-collection-flaky-voter-race

Conversation

@generall

@generall generall commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • test_consensus_snapshot_create_collection killed the last peer right after start_cluster. start_cluster only waits for a uniform leader/peer-count, not for learner→voter promotion.
  • If the last peer caught up first, the leader promoted it to voter while the other peer was still a learner. Killing it left voters [leader, dead], learners [alive] — quorum 2/2 with 1 alive, so the subsequent CreateCollection couldn't commit and timed out after 10s.
  • Wait for all_peers_are_voters after start_cluster so killing one peer leaves a 2-of-3 voter quorum. Promoted the existing local helper in test_learners_promoted_to_voters.py into utils.py for reuse.

Captured failure: tests/consensus_tests/test_consensus_compaction.py::test_consensus_snapshot_create_collection[2] returned 500 Waiting for consensus operation commit failed. Timeout set at: 10 seconds. The same race applies to [1] (lower probability, same fix).

Test plan

  • CI passes
  • Run pytest tests/consensus_tests/test_consensus_compaction.py::test_consensus_snapshot_create_collection -k 2 --count=20 locally to confirm the race is gone
  • test_learners_promoted_to_voters still passes after the helper move

🤖 Generated with Claude Code

The test killed the last peer immediately after start_cluster, but
start_cluster only waits for cluster size and a known leader — not for
all peers to be promoted from learner to voter. If the last peer caught
up first, it became the only other voter alongside the leader; killing
it left a 2-of-2 quorum with one voter dead, and the subsequent
CreateCollection commit timed out after 10s.

Wait for all peers to be voters before killing one, so the survivors
form a 2-of-3 voter quorum.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@generall
generall merged commit edde26e into dev May 7, 2026
15 checks passed
@generall
generall deleted the fix/consensus-snapshot-create-collection-flaky-voter-race branch May 7, 2026 21:35
@qdrant qdrant deleted a comment from coderabbitai Bot May 8, 2026
timvisee pushed a commit that referenced this pull request May 8, 2026
…8951)

The test killed the last peer immediately after start_cluster, but
start_cluster only waits for cluster size and a known leader — not for
all peers to be promoted from learner to voter. If the last peer caught
up first, it became the only other voter alongside the leader; killing
it left a 2-of-2 quorum with one voter dead, and the subsequent
CreateCollection commit timed out after 10s.

Wait for all peers to be voters before killing one, so the survivors
form a 2-of-3 voter quorum.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant