Skip to content

test(search): fix flaky legacy desc vector test caused by Meilisearch task batching - #4676

Merged
strelov1 merged 1 commit into
mainfrom
fix/search-legacy-vectors-flake
Nov 15, 2026
Merged

strelov1 merged 1 commit into
mainfrom
fix/search-legacy-vectors-flake

Conversation

@strelov1

@strelov1 strelov1 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

TestIntegration_MarkersSurviveLegacyDescriptionVectors failed now and then with doc 1 kept the retired desc vectors (for example on #4591, which does not touch internal/search; the rerun passed). It was a race in the test setup, not in the closure code.

Cause

The setup retired the desc embedder through EnsureIndex. That function queues "reset embedders" and then the new settings, without awaiting the reset in between (on purpose, see ensure). Meilisearch may or may not put both tasks into one batch:

  • Two batches (the usual case): the reset moves the user-provided desc vectors into the document bodies, and the closure edit function deletes them. This is the production state the test is about.
  • One batch (when the engine is slow): Meilisearch applies only the net change, {skills, desc} to {skills}. The desc vectors are not moved into the document bodies, so the edit function never sees them, yet retrieveVectors still returns them. The assertion fails.

Evidence (local Meilisearch v1.49.0, throwaway loop that logs batchUid for every task):

Scenario Result
Original test, -count=20, machine under heavy load 1 failure in 40 subtests, same message as CI
200 iterations, light load 0 failures; reset and settings always in separate batches
Meilisearch limited to 0.2 CPU, 20 iterations 1 failure; in that iteration reset and settings shared one batch, and the plain document had no _vectors field
One batch forced (global queue held by a slow task, then the same calls ensure makes) 5 of 5 failed
The same forced batch, after a standalone awaited reset 5 of 5 passed

Fix

The test now awaits a standalone ResetEmbedders before EnsureIndex. The desc vectors always end up in the document bodies, however EnsureIndex's own tasks are batched. Product code is unchanged. In the one-batch case the closure edit still succeeded and set every marker. The only leftover is unused desc vectors in the vector store.

Checks

  • go test -tags=integration -run TestIntegration_MarkersSurviveLegacyDescriptionVectors -count=20 ./internal/search/search/: 40/40 passed, run twice (once with Meilisearch at 0.2 CPU)
  • gofmt -l, go vet ./..., go vet -tags=integration ./..., go test ./internal/search/...: clean

Created with Claude Opus 5.5 in Claude Code.


Note

Low Risk
Test-only change to integration setup; no production behavior modified.

Overview
Stabilizes TestIntegration_MarkersSurviveLegacyDescriptionVectors by awaiting a standalone ResetEmbedders after seeding legacy desc chunk vectors and before EnsureIndex.

That ordering removes a flaky setup race: when Meilisearch batches the reset with EnsureIndex's settings update, desc vectors may never land in document bodies, so the closure edit function cannot strip them and the test intermittently fails with “kept the retired desc vectors.” Production search code is unchanged—only test setup and comments are updated.

Reviewed by Cursor Bugbot for commit 1dbb26f. Bugbot is set up for automated code reviews on this repo. Configure here.

TestIntegration_MarkersSurviveLegacyDescriptionVectors failed now and then
with "doc 1 kept the retired desc vectors".

The setup retired the `desc` embedder through EnsureIndex, which queues a
reset of the embedders and the new settings without awaiting the reset in
between. Usually Meilisearch runs them as two batches: the reset moves the
user-provided desc vectors into the document bodies, where the closure
edit function deletes them. When the engine is slow, both tasks land in
one batch and Meilisearch applies only the net change ({skills, desc} to
{skills}). The desc vectors then stay out of the document bodies, so the
function cannot see them, yet retrieveVectors still returns them.

The setup now awaits a standalone reset before EnsureIndex, which always
produces the production state the test is about.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f455764 and 1dbb26f.

Files selected for processing: 1

  • internal/search/search/closure_legacy_vectors_integration_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T22:17:34.493665Z 1dbb26f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor

cursor Bot commented Nov 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e7db810f-39bb-43ab-89ce-ff915031d4a1)

@strelov1
strelov1 enabled auto-merge (squash) November 15, 2026 22:37
@strelov1
strelov1 merged commit f9afab6 into main Nov 15, 2026
47 of 49 checks passed
@strelov1
strelov1 deleted the fix/search-legacy-vectors-flake branch November 15, 2026 22:45
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