From b947ecd36cdedb163ffada8c05359ec4d6bccc66 Mon Sep 17 00:00:00 2001 From: root <111755117+qdrant-cloud-bot@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:09:07 +0000 Subject: [PATCH] test: fix flaky test_partial_snapshot optimizer race Wait for green on write (and read after recover_read) so collection and partial snapshots are not taken mid-indexing. Otherwise a leftover appendable segment survives partial merge and breaks manifest equality. Co-authored-by: Cursor --- tests/consensus_tests/test_partial_snapshot.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/consensus_tests/test_partial_snapshot.py b/tests/consensus_tests/test_partial_snapshot.py index e7733c06c6..f8a1a79ce2 100644 --- a/tests/consensus_tests/test_partial_snapshot.py +++ b/tests/consensus_tests/test_partial_snapshot.py @@ -79,12 +79,24 @@ def test_partial_snapshot( ): assert_project_root() + # Wait for the write peer to finish indexing before the recover_read + # collection snapshot is taken. Otherwise the snapshot can capture a + # mid-optimization appendable segment that the write peer later drops; + # partial recovery merges into the read peer and preserves that leftover, + # so assert_files_consistency fails (see test_partial_snapshot[100-True-0--5]). write_peer, read_peer = bootstrap_peers( tmp_path, bootstrap_points = bootstrap_points, recover_read = recover_read, + wait_for_green = True, ) + if recover_read: + # Same race as test_partial_snapshot_empty: after collection-snapshot + # recovery, async optimization on the read peer can reshape segments + # before we take the partial snapshot. + wait_collection_green(read_peer, COLLECTION) + if append_points > 0: upsert(write_peer, append_points, offset = bootstrap_points) @@ -94,6 +106,11 @@ def test_partial_snapshot( if update_points < 0: delete(write_peer, -update_points) + if append_points > 0 or update_points != 0: + # Mutations (especially appends with indexing_threshold=1) can start + # another optimization; wait so the partial snapshot is not mid-opt. + wait_collection_green(write_peer, COLLECTION) + recover_partial_snapshot_from(read_peer, write_peer) assert_consistency(read_peer, write_peer)