Fixes #2068 - Silent thread leak on exception in completeValueForList #2359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This an attempt to fix #2068 . It might be a bit too naive, but i wanted to get another set of eyes on this issue.
Here my reasoning for this fix:
As explained in the issue, the problem lies in how the dataloader determines when to dispatch different levels. When one of the
resolveFieldWithInfofutures completes exceptionally, theAsync.eachFuture also completes exceptionally and the dataloader instrumentation is not made aware of this. SinceexpectedStrategyCallsPerLevelis increased by calls tohandleOnFieldValuesInfoby previous levels andallOnFieldCallsHappenedis checked for the previous level when dispatching, it means that all deeper levels will never be dispatched (expectedStrategyCallsPerLevelis bigger thanhappenedOnFieldValueCallsPerLevel) and we leak a thread. The changes made make sure that the instrumentation is made aware of this exceptional completion and thus that deeper levels can still be dispatched.If you have better ideas to fix this i am open for your suggestions! Thanks!