Skip to content

Test for segment double proxies#7127

Merged
agourlay merged 1 commit intodevfrom
double-proxy-test
Aug 25, 2025
Merged

Test for segment double proxies#7127
agourlay merged 1 commit intodevfrom
double-proxy-test

Conversation

@agourlay
Copy link
Member

@agourlay agourlay commented Aug 25, 2025

This test was used to detect the bug fixed by #7109

This PR proposes to keep the test to avoid regressions in the future.

@agourlay agourlay marked this pull request as ready for review August 25, 2025 09:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

📝 Walkthrough

Walkthrough

Adds a new test test_double_proxies in lib/shard/src/segment_holder/tests.rs. The test imports only_default_vector and sets up inner and outer proxy segments via SegmentHolder. It performs delete_point through the inner proxy and upsert_point through the outer proxy using only_default_vector. It then unproxies in two steps and asserts that exactly one new segment remains by comparing segment IDs before and after the operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • timvisee
  • generall

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch double-proxy-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
lib/shard/src/segment_holder/tests.rs (4)

6-6: Nit: avoid mixing fully-qualified and imported only_default_vector usage in the same file

The new import brings only_default_vector into scope, but most existing tests in this file still call it via the fully-qualified path. Consider unifying on one style for consistency (either keep the import and migrate older call sites later, or drop the import and use the fully-qualified path here).

If you prefer to keep the existing style in this file, apply the following edits:

- use segment::data_types::vectors::{DEFAULT_VECTOR_NAME, VectorInternal, only_default_vector};
+ use segment::data_types::vectors::{DEFAULT_VECTOR_NAME, VectorInternal};

And in the new test (see suggested edit below in the relevant hunk), call segment::data_types::vectors::only_default_vector(...) instead of the unqualified name.


613-621: Guard against accidental empty/extra proxies before indexing

We index inner_proxies[0] directly. While the setup creates exactly one segment today, an explicit assertion improves failure diagnostics and prevents a panic if the setup changes.

     // check inner proxy contains points
+    assert_eq!(inner_proxies.len(), 1, "expected exactly one inner proxy");
     let points = inner_proxies[0]
         .1
         .get()
         .read()
         .read_range(Some(1.into()), None);

633-645: Minor clarity: use [0.0; 4] for vector construction (matches the rest of the file)

Elsewhere in this file tests use the [0.0; 4] shorthand. Using it here keeps the style consistent.

Also see previous comment if you opt to keep fully-qualified calls to only_default_vector.

-        .upsert_point(
+        .upsert_point(
             100,
             1.into(),
-            only_default_vector(&[0.0, 0.0, 0.0, 0.0]),
+            only_default_vector(&[0.0; 4]),
             &hw_counter,
         )

If you choose the fully-qualified form for consistency with the rest of the file:

-            only_default_vector(&[0.0; 4]),
+            segment::data_types::vectors::only_default_vector(&[0.0; 4]),

660-667: Strengthen the postcondition: verify the upserted point resides in the new segment only

Asserting the presence of the newly appended segment is good. To make the test more robust (and closer to the bug’s behavioral contract), assert that:

  • the new segment contains point 1, and
  • the original segment no longer contains point 1 (deleted via the inner proxy and not reintroduced there).
     // Check that we have one new segment
     let diff: HashSet<_> = after_segment_ids.difference(&before_segment_ids).collect();
     assert_eq!(
         diff.len(),
         1,
         "There should be one new segment after unproxying"
     );
+
+    // Additionally, ensure point `1` moved to the new temp segment and is absent from the original
+    let &new_sid = diff.iter().next().expect("new segment id must exist");
+    let &old_sid = before_segment_ids.iter().next().expect("original segment id must exist");
+    let new_seg_read = holder.get(*new_sid).unwrap().get().read();
+    assert!(new_seg_read.has_point(1.into()), "new segment should contain point 1 after upsert");
+    drop(new_seg_read);
+    let old_seg_read = holder.get(old_sid).unwrap().get().read();
+    assert!(
+        !old_seg_read.has_point(1.into()),
+        "original segment should not contain point 1 after delete"
+    );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f2ce816 and 5ea18b3.

📒 Files selected for processing (1)
  • lib/shard/src/segment_holder/tests.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-11T11:35:21.549Z
Learnt from: generall
PR: qdrant/qdrant#6854
File: lib/segment/src/index/query_estimator.rs:320-327
Timestamp: 2025-07-11T11:35:21.549Z
Learning: In test code for Qdrant's query estimator (lib/segment/src/index/query_estimator.rs), simplified ID resolution logic using `id.to_string().parse().unwrap()` is acceptable for testing purposes and doesn't need to match production code's `id_tracker.internal_id()` approach. Test code can use mock implementations that serve the testing goals.

Applied to files:

  • lib/shard/src/segment_holder/tests.rs
🧬 Code graph analysis (1)
lib/shard/src/segment_holder/tests.rs (3)
lib/segment/src/data_types/vectors.rs (1)
  • only_default_vector (471-473)
lib/common/common/src/save_on_disk.rs (1)
  • load_or_init_default (38-43)
lib/shard/src/segment_holder/mod.rs (3)
  • proxy_all_segments (1063-1139)
  • unproxy_all_segments (1200-1264)
  • len (99-101)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: rust-tests (windows-latest)
  • GitHub Check: integration-tests-consensus
🔇 Additional comments (1)
lib/shard/src/segment_holder/tests.rs (1)

579-667: LGTM: solid regression test for nested proxy/unproxy with a single temp-segment append

The scenario is clear: inner proxy receives a delete, outer proxy receives an upsert, then double unproxy asserts exactly one new segment ID. This should prevent regressions like the one fixed in #7109.

@agourlay agourlay requested a review from timvisee August 25, 2025 10:34
@agourlay agourlay merged commit db2489b into dev Aug 25, 2025
16 checks passed
@agourlay agourlay deleted the double-proxy-test branch August 25, 2025 12:20
timvisee pushed a commit that referenced this pull request Aug 26, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 6, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 14, 2025
6 tasks
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.

2 participants