Repository navigation
[Fusion] Fix previous schemas not being garbage collected - #10654
Merged
michaelstaib merged 10 commits intoOct 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused ownership and clearing changes address schema retention without invalidating published storage, with regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes Fusion retaining replaced schemas through pooled operation storage.
Changes:
- Clears rented arrays and private arrays returned to the pool.
- Keeps published arrays out of the pool while readers may still reference them.
- Adds regression tests for storage reuse, growth, and schema collection.
| File | Description |
|---|---|
| src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/OperationCompilerTests.cs | Tests array clearing, published storage preservation, and schema release. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationCompiler.cs | Clears pooled storage and tracks whether arrays can safely be returned. |
Review effort: Balanced
An unused capacity can retain old operations along with their associated service providers
tobias-tengler
force-pushed
the
fix-executor-swap-memory-leak
branch
from
October 21, 2026 12:11
7275361 to
5eb705c
Compare
Member
|
Thanks @mnebes :) |
tobias-tengler
force-pushed
the
fix-executor-swap-memory-leak
branch
from
October 21, 2026 12:24
4c661f5 to
926ab92
Compare
Contributor
Author
Yeah, that works too :) |
The composite selector returned its rented Selection buffer without clearing it, so the shared pool kept selections, and with them the previous schema, alive after an executor swap.
A lazy compile that failed after allocating ids left the operation's last id ahead of its storage, so the next lazy compile threw an IndexOutOfRangeException. The tests now also cover the previous storage staying intact when it grows, dispose the Fusion schemas, and wait up to 30 seconds for the previous schema to be collected.
This file contains hidden or 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
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.
We noticed that our gateway instances accumulated
gen2memory significantly over time:(yellow line is gen2)
We also noticed that the memory grows whenever we update the composed schema, which lead us to believe that somehow the caches are not released whenever a switchover happens. Our hypothesis is that selections left in pooled
object[]tails can reference their declaring operation and schema. A replacement schema's cached operation can therefore retain an old schema, its disposed service provider, and that provider's cached operations. This can be then chained ever deeper. A subsequent memory dump analysis seems to support this hypothesis:This PR is a proposed fix that:
The replaced published arrays are therefore left to GC to clean up; unpublished intermediate arrays remain pooled.
As always, let me know if you need anything from me 🙂