Fix OOM crash, when closing a transaction while Queries are still ongoing #1193
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 closing a transaction while queries are still running, the
_onErrorCallbacks
will cause an infinite loop which leads to an OOM crash.Because
FAILED
is only set as a state in this function, I opted to use it as a failsafe check, to cut the recursion short.The test triggers the OOM crash when the fix is not included, otherwise it passes in <1s on my machine.
I hope the test is ok as it is, let me know if you need any changes for this.
EDIT: Upon a bit further testing, it's not actually infinite, but just scaling exponentially.
3 simultaneous queries gets us ~3000
_onErrorCallback
calls,4 gets us ~32000,
5 gets us ~195000,
6 gets us ~840000,
7-12 gets us "Map maximum size exceeded"
13+ gets us the mentioned OOM