Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix runtime exception for deep async queries #2842

Merged
merged 2 commits into from Jun 8, 2022

Conversation

jbellenger
Copy link
Contributor

@jbellenger jbellenger commented May 31, 2022

Problem
Resolving large queries with more than 16 async levels throws this error:

java.lang.IllegalArgumentException: unknown level 16
	at graphql.execution.instrumentation.dataloader.LevelMap.get(LevelMap.java:35)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach$CallStack.allStrategyCallsHappened(FieldLevelTrackingApproach.java:65)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach.levelReady(FieldLevelTrackingApproach.java:238)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach.dispatchIfNeeded(FieldLevelTrackingApproach.java:223)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach.handleOnFieldValuesInfo(FieldLevelTrackingApproach.java:177)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach.access$000(FieldLevelTrackingApproach.java:26)
	at graphql.execution.instrumentation.dataloader.FieldLevelTrackingApproach$1.onFieldValuesInfo(FieldLevelTrackingApproach.java:147)
	at graphql.execution.AsyncExecutionStrategy.lambda$execute$1(AsyncExecutionStrategy.java:73)

The issue appears to be that inside FieldLevelTrackingApproach.levelReady, we're checking the allFetchesHappened LevelMap when it may not have been expanded to the specified level. This is not an issue for small queries that can fit under the default size of 16 levels, but throws an exception for more nested async queries. This issue effects all "happened"-ish LevelMaps in FieldLevelTrackingApproach

Solution
In LevelMap.get automatically resize if needed. This allows deep queries to match the behavior of shallow queries which do not need to resize their LevelMaps.

@jbellenger jbellenger changed the title ensure that happenedOnFieldValueCallsPerLevel has required capacity fix runtime exception for deep async queries May 31, 2022
}
Copy link
Member

Choose a reason for hiding this comment

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

Cool - some more lines ;)

@bbakerman bbakerman added this to the 19.0 milestone Jun 8, 2022
@bbakerman bbakerman merged commit 3379470 into graphql-java:master Jun 8, 2022
@bbakerman
Copy link
Member

Thank you for this

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.

None yet

2 participants