[
https://issues.apache.org/jira/browse/DRILL-6348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16455789#comment-16455789
]
ASF GitHub Bot commented on DRILL-6348:
---------------------------------------
Github user vrozov commented on a diff in the pull request:
https://github.com/apache/drill/pull/1237#discussion_r184596895
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatch.java
---
@@ -77,4 +83,46 @@ public long getByteCount() {
public boolean isAckSent() {
return ackSent.get();
}
+
+ /**
+ * Transfer ownership of this DrillBuf to the target allocator. This is
done for better memory
+ * accounting (that is, the operator should be charged with the body's
Drillbuf memory).
+ *
+ * <p><b>NOTES -</b>
+ * <ul>
+ * <li>This operation is a NOOP when a) the current allocator
(associated with the DrillBuf) is not the
+ * owning allocator or b) the target allocator is already the owner
+ * <li>When transfer happens, a new RawFragmentBatch instance is
allocated; this is done for proper
+ * DrillBuf reference count accounting
+ * <li>The RPC handling code caches a reference to this RawFragmentBatch
object instance; release()
+ * calls should be routed to the previous DrillBuf
+ * </ul>
+ *
+ * @param targetAllocator target allocator
+ * @return a new {@link RawFragmentBatch} object instance on success
(where the buffer ownership has
+ * been switched to the target allocator); otherwise this
operation is a NOOP (current instance
+ * returned)
+ */
+ public RawFragmentBatch transferBodyOwnership(BufferAllocator
targetAllocator) {
+ if (body == null) {
+ return this; // NOOP
+ }
+
+ if (!body.getLedger().isOwningLedger()
+ || body.getLedger().isOwner(targetAllocator)) {
+
+ return this;
+ }
+
+ int writerIndex = body.writerIndex();
+ TransferResult transferResult =
body.transferOwnership(targetAllocator);
+
+ // Set the index and increment reference count
+ transferResult.buffer.writerIndex(writerIndex);
+
+ // Clear the current Drillbuffer since caller will perform release()
on the new one
+ body.release();
+
+ return new RawFragmentBatch(getHeader(), transferResult.buffer,
getSender(), false);
--- End diff --
This actually brings a question why `newRawFragmentBatch` is released in
`IncomingBuffers.batchArrived()` instead of releasing `transferredBuffer` after
`RawFragmentBatch` is constructed in `newRawFragmentBatch`.
> Unordered Receiver does not report its memory usage
> ---------------------------------------------------
>
> Key: DRILL-6348
> URL: https://issues.apache.org/jira/browse/DRILL-6348
> Project: Apache Drill
> Issue Type: Task
> Components: Execution - Flow
> Reporter: salim achouche
> Assignee: salim achouche
> Priority: Major
> Fix For: 1.14.0
>
>
> The Drill Profile functionality doesn't show any memory usage for the
> Unordered Receiver operator. This is problematic when analyzing OOM
> conditions since we cannot account for all of a query memory usage. This Jira
> is to fix memory reporting for the Unordered Receiver operator.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)