Ensure memory is freed in SpoolingExchangeOutputBuffer#13717
Ensure memory is freed in SpoolingExchangeOutputBuffer#13717arhimondr merged 1 commit intotrinodb:masterfrom
Conversation
Close memory context to prevent race condition when memory is reserved in enqueuePage after output buffer destroy following the pattern used in other output buffers
| { | ||
| LocalMemoryContext context = getSystemMemoryContextOrNull(); | ||
| if (context != null) { | ||
| context.close(); |
There was a problem hiding this comment.
not every memory context is closeable, see https://github.com/trinodb/trino/pull/13213/files#diff-1774b86bf4c8b2248f02693fe0b0c6acc38305a6773ca813f5957601207a8168R338.
I think we can assume that only memory context created from io.trino.memory.context.AggregatedMemoryContext#newAggregatedMemoryContext are closeable
There was a problem hiding this comment.
The other output buffers close the memory context through the OutputBufferMemoryManager: https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/execution/buffer/OutputBufferMemoryManager.java#L199
The memory context is closeable. It is created in https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/operator/TaskContext.java#L157 through https://github.com/trinodb/trino/blob/master/lib/trino-memory-context/src/main/java/io/trino/memory/context/MemoryTrackingContext.java#L136
Description
Close memory context to prevent race condition when memory is reserved
in enqueuePage after output buffer destroy following the pattern used in
other output buffers
Fix
Core engine
N/ARelated issues, pull requests, and links
#13362
Documentation
(X) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(X) No release notes entries required.
( ) Release notes entries required with the following suggested text: