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

Strawberry Shake Dictionary Type Parameters Memory Leak #5382

Closed
1 task done
declan-bourke opened this issue Sep 9, 2022 · 0 comments · Fixed by #5383
Closed
1 task done

Strawberry Shake Dictionary Type Parameters Memory Leak #5382

declan-bourke opened this issue Sep 9, 2022 · 0 comments · Fixed by #5383

Comments

@declan-bourke
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Related to #3513

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).

Steps to reproduce

Steps to reproduce the behaviour:

  1. Execute ExecuteAsync on a query which has a dictionary type variable parameter
  2. After 2 or more completed executions of the above with identical parameters on that same query upon inspecting _operationExecutor -> _operationStore -> _results it will be observed that another result gets added after each time

Relevant log output

No response

Additional Context?

Expected behaviour
If one of the variables is a list type, the contents of that dictionary needs to iterated and compared so that the comparison when GetOrAdd is executed correctly recognises that is another call to the same query and therefore the existing result should updated, not another one added; i.e. Get is triggered not Add.

Desktop (please complete the following information):

  • OS: Windows 10
  • .net: 6.0/7.0

Additional context
Using 12.3.0 Strawberry Shake, but checking the code, latest remains affected by this bug.

Product

Strawberry Shake

Version

12.3.0

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

Successfully merging a pull request may close this issue.

3 participants