-
-
Notifications
You must be signed in to change notification settings - Fork 748
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 memory leak bug caused by query dictionary variable params #5383
Merged
michaelstaib
merged 7 commits into
ChilliCream:main
from
declan-bourke:db/fix-dictionary-type-param-compare
Sep 14, 2022
Merged
Fix memory leak bug caused by query dictionary variable params #5383
michaelstaib
merged 7 commits into
ChilliCream:main
from
declan-bourke:db/fix-dictionary-type-param-compare
Sep 14, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When invoking queries where one or more of the variable parameters is a dictionary, this causes every repeat execution of the query to add another operation result to the operation store after every completed ExecuteAsync request. This is caused by the fact that the call to GetOrAddStoredOperation in OperationStore performs a GetOrAdd on the ConcurrentDictionary<OperationRequest, IStoredOperation> _result, the .Equals equality comparison within the OperationRequest object that acts as the key and thus invoked by GetOrAdd, when comparing the content of variables will always return false with a dictionary variable because it treats it as an IEnumerable and ComparisonHelper.SequenceEqual only works for lists and not dictionaries so therefore returns false. The result is that every invocation adds another item to _results which will keep growing indefinitely, triggering a memory leak as well as higher and higher cpu usage (every time more items in _results needs to be compared to). Co-Authored-By: davidbrazel2 <47366627+davidbrazel2@users.noreply.github.com>
@declan-bourke can you sign the CLA please. |
I will review this tonight. |
michaelstaib
approved these changes
Sep 14, 2022
Will this be backported to v12? |
@lweberprb we are not far off the V13 release. So, I think it's not worth it. But If you want to have a go at it you can create a PR for the |
la-we
pushed a commit
to la-we/hotchocolate
that referenced
this pull request
Nov 30, 2022
This was referenced Jan 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When invoking queries where one or more of the variable parameters is a dictionary, this causes every repeat execution of the query to add another operation result to the operation store after every completed ExecuteAsync request. This is caused by the fact that the call to GetOrAddStoredOperation in OperationStore performs a GetOrAdd on the ConcurrentDictionary<OperationRequest, IStoredOperation> _result, the .Equals equality comparison within the OperationRequest object that acts as the key and thus invoked by GetOrAdd, when comparing the content of variables will always return false with a dictionary variable because it treats it as an IEnumerable and ComparisonHelper.SequenceEqual only works for lists and not dictionaries so therefore returns false. The result is that every invocation adds another item to _results which will keep growing indefinitely, triggering a memory leak as well as higher and higher cpu usage (every time more items in _results needs to be compared to).
Co-Authored-By: davidbrazel2 47366627+davidbrazel2@users.noreply.github.com
Summary of the changes (Less than 80 chars)
Closes #5382