Feature/merge memory monitoring #21941
Open
+262
−41
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.
Scope & Purpose
This PR introduces memory supervision to the MERGE instruction in the Aql query runtime.
MERGE previously constructed its result with an unsupervised velocypack::Buffer, mean
ing temporary allocations were invisible to the query’s ResourceMonitor.
In intermediate steps of the query processing, if a VPackBuilder is used as auxiliary storage structure and a resource monitor for the query is available, instead of creating a builder wrapping a regular Buffer, we use a supervised buffer, from lib/Basics/SupervisedBuffer.h. This buffer internally increases/decreases memory which the resource monitor accounts, because, temporarily, it can expand the memory consumption up to a value that could make the query surpass its memory limit. Also, Aql values can build up the memory usage, so they are also supervised and increase/decrease the memory monitor, so memory is properly accounted. With this, when the memory limit is surpassed, instead of crashing the system, the query crashes, allowing for the system to keep running.
Obs.: this is a companion to #21936, which implements supervision for the COLLECT instruction.
Checklist
Related Information
(Please reference tickets / specification / other PRs etc)