Skip to content

Query prefetch fix - #32122

Merged
jeet1995 merged 19 commits into
Azure:mainfrom
jeet1995:QueryPrefetchFix
Nov 16, 2022
Merged

Query prefetch fix#32122
jeet1995 merged 19 commits into
Azure:mainfrom
jeet1995:QueryPrefetchFix

Conversation

@jeet1995

@jeet1995 jeet1995 commented Nov 12, 2022

Copy link
Copy Markdown
Member

Description

An upstream operator such as flatMapSequential or mergeSequential cannot control the demand of a downstream flatMap operator despite a prefetch set on that upstream. This results in pages to be eagerly fetched since the downstream flatMap requests for 32 or 256 items.

More details here: Issue: 3275
Fixes #32010

Fix

The fix is for the downstream flatMap to have a prefetch of its own. In order to minimize prefetch as much as possible, the downstream flatMap should take a prefetch of 1.

Tests

Added a unit test validatePrefetchControl to simulate the effects of eager and lazy prefetching by setting the prefetch value on a downstream flatMap operator.

Benchmarking

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jeet1995 jeet1995 changed the title Query prefetch fix [DO NOT MERGE]: Query prefetch fix Nov 12, 2022
@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jeet1995 jeet1995 changed the title [DO NOT MERGE]: Query prefetch fix Query prefetch fix Nov 14, 2022

@kushagraThapar kushagraThapar 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.

Great work @jeet1995 , thanks for fixing this issue.
The PR looks good to me, however, blocking it until we have performance benchmark numbers.

@kushagraThapar

Copy link
Copy Markdown
Member

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kushagraThapar kushagraThapar 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.

LGTM, thanks @jeet1995
please do add a changelog for jackson vulnerability fix which is also shipping in this version.
Can be done once live tests are done.

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel FabianMeiswinkel 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.

LGTM - Thanks!

@xinlian12 xinlian12 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.

LGTM, thanks for the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure Cosmos Java SDK query prefetches too many pages eagerly

4 participants