Skip to content

[BUG] Cosmos P1: Non-streaming vector TOP queries silently discard winning results #51133

Open

Description

Describe the bug
Alan Zimmer's November 6, 2026 audit of com.azure:azure-cosmos:4.84.0-beta.1 reports that a streaming ORDER BY fetch-page optimization also reduces the non-streaming merge's candidate-retention limit. With six ranges and TOP 60, that limit becomes 50. If winning results are concentrated in one range, valid candidates are discarded, yielding too few results or worse matches. Reported priority: P1; silent incorrect query results.

Exception or Stack Trace
N/A; results are silently incorrect.

To Reproduce
Execute a non-streaming vector TOP 60 query across six skewed ranges, with the winning candidates concentrated in one range. Exercise the factory and query pipeline and compare exact top-K membership against an unrestricted reference result.

Code Snippet
No complete executable snippet was supplied. Reported locations: DocumentQueryExecutionContextFactory.java:525-536 and NonStreamingOrderByUtils.java:95-109 in the audited source.

Expected behavior
Fetch-page sizing must not reduce the number of candidates retained for the global top-K merge; all 60 winning results must be retained and returned.

Screenshots
N/A.

Setup (please complete the following information):

  • OS: Not reported.
  • IDE: Not reported.
  • Library/Libraries: com.azure:azure-cosmos:4.84.0-beta.1.
  • Java version: Not reported.
  • App Server/Environment: Non-streaming vector query over six ranges.
  • Frameworks: Not reported.

Dependency mismatch: Not indicated; dependency tree/logs were not supplied.

Additional context
Proposed fix from the audit: separate fetch-page sizing from candidate retention, or exclude non-streaming queries from the streaming optimization.

Regression coverage: exercise the factory/pipeline with six skewed ranges and verify exact top-K membership, not only result count.

Reported reproduction: compiled current-source query components retained 50 results versus 60 with the correct limit. The probe supplied the factory-derived limit and was not a full factory integration test; cached supporting dependencies were used. No live Cosmos calls or full SDK test suite were run, and no repository files were changed. This issue tracks validation and implementation of the proposed fix, not an already-applied fix. Alan recommended addressing this and the failed change-feed initialization finding first.

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Cosmos

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions