Skip to content

Azure Cosmos Java SDK query prefetches too many pages eagerly #32010

Description

@kushagraThapar

Query APIs in azure-cosmos Java SDK is prefetching too many pages eagerly even if the client's application is blocking on the first page.
This affects both sync and async APIs. Eagerly prefetching is causing increase in RUs, as it is draining all the pages in the background.

Sample code to repro:

        CosmosQueryRequestOptions cosmosQueryRequestOptions = new CosmosQueryRequestOptions();
        cosmosQueryRequestOptions.setMaxBufferedItemCount(10);
        CosmosPagedIterable<ObjectNode> cosmosPagedIterable = cosmosContainer.queryItems("select * from c",
            cosmosQueryRequestOptions, ObjectNode.class);

        Iterable<FeedResponse<ObjectNode>> feedResponses = cosmosPagedIterable.iterableByPage(10);
        //  Just creating iterator drains all the results!
        Iterator<FeedResponse<ObjectNode>> iterator = feedResponses.iterator();

We have created an issue in project reactor repo to track why the prefetching is not working as expected - reactor/reactor-core#3275

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Cosmosazure-cosmos-paginationcosmos:v4-itemIndicates this feature will be shipped as part of V4 release train

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions