Skip to content

Fix flaky test_cancel_optimization - #8159

Merged
timvisee merged 1 commit into
qdrant:devfrom
leohenon:fix/flaky-cancel-optimization-7794
Feb 18, 2026
Merged

timvisee merged 1 commit into
qdrant:devfrom
leohenon:fix/flaky-cancel-optimization-7794

Conversation

@leohenon

Copy link
Copy Markdown
Contributor

Relax log count assertion from assert_eq! to <=.
Early cancellations are intentionally excluded from log (optimization_worker.rs:376).

Fixes #7794

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Copilot AI review requested due to automatic review settings February 17, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a flaky test test_cancel_optimization that was failing intermittently on Windows. The test was asserting an exact count of logged optimizations, but optimizations that are cancelled very early (before they successfully start) are intentionally excluded from the log to avoid clutter. The fix relaxes the assertion from strict equality to a less-than-or-equal comparison.

Changes:

  • Changed assertion from assert_eq!(log.len(), expected_optimization_count) to assert!(log.len() <= expected_optimization_count) to account for early-cancelled optimizations not being logged

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qdrant qdrant deleted a comment from coderabbitai Bot Feb 17, 2026
@timvisee

Copy link
Copy Markdown
Member

I'm not confident yet this change is correct.

Are cancellations even relevant here? Don't they follow up with a new optimization to still satisfy that count assertion?

@leohenon

Copy link
Copy Markdown
Contributor Author

I'm not confident yet this change is correct.

Are cancellations even relevant here? Don't they follow up with a new optimization to still satisfy that count assertion?

No retry here. The test calls launch_optimization directly. Then stop() is called on all of them. If a task gets cancelled before reaching on_successful_start, it never gets added to the log.

I considered polling for the log to be populated, but went with the smaller fix since the name + status assertions still cover every entry that makes it into the log. The race only drops entries, never produces false ones.

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for tackling this one! 😄

@timvisee
timvisee merged commit b9f543d into qdrant:dev Feb 18, 2026
20 of 21 checks passed
@leohenon
leohenon deleted the fix/flaky-cancel-optimization-7794 branch February 18, 2026 13:15
timvisee pushed a commit that referenced this pull request Feb 18, 2026
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
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.

3 participants