boneanxs opened a new issue, #10087:
URL: https://github.com/apache/incubator-gluten/issues/10087
### Backend
VL (Velox)
### Bug description
The job are failed with the exception:
```java
Reason: Operator::getOutput failed for [operator: ValueStream, plan node ID:
0]: Error during calling Java code from native code:
org.apache.gluten.memory.memtarget.ThrowOnOomMemoryTarget$OutOfMemoryException:
Not enough spark off-heap execution memory. Acquired: 1024.0 MiB, granted:
968.0 MiB. Try tweaking config option spark.memory.offHeap.size to get larger
space to run this application (if
spark.gluten.memory.dynamic.offHeap.sizing.enabled is not enabled).
Current config settings:
spark.gluten.memory.offHeap.size.in.bytes=3.0 GiB
spark.gluten.memory.task.offHeap.size.in.bytes=3.0 GiB
spark.gluten.memory.conservative.task.offHeap.size.in.bytes=1536.0 MiB
spark.memory.offHeap.enabled=true
spark.gluten.memory.dynamic.offHeap.sizing.enabled=false
Memory consumer stats:
Task.1107: Current
used bytes: 2.1 GiB, peak bytes: N/A
\- Gluten.Tree.4: Current
used bytes: 2.1 GiB, peak bytes: 3.0 GiB
\- Capacity[8.0 EiB].4: Current
used bytes: 2.1 GiB, peak bytes: 3.0 GiB
+- NativePlanEvaluator-9.0: Current
used bytes: 1184.0 MiB, peak bytes: 1200.0 MiB
| \- single: Current
used bytes: 1184.0 MiB, peak bytes: 1200.0 MiB
| +- root: Current
used bytes: 1176.2 MiB, peak bytes: 1195.0 MiB
| | +- task.Gluten_Stage_0_TID_1107_VTID_9: Current
used bytes: 1176.2 MiB, peak bytes: 1195.0 MiB
| | | +- node.1: Current
used bytes: 1176.2 MiB, peak bytes: 1184.0 MiB
| | | | \- op.1.0.0.FilterProject: Current
used bytes: 1176.2 MiB, peak bytes: 1176.4 MiB
| | | +- node.2: Current
used bytes: 0.0 B, peak bytes: 11.0 MiB
| | | | \- op.2.0.0.OrderBy: Current
used bytes: 0.0 B, peak bytes: 4.5 MiB
| | | \- node.0: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| | | \- op.0.0.0.ValueStream: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| | \- default_leaf: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- ArrowContextInstance.1: Current
used bytes: 576.0 MiB, peak bytes: 1616.0 MiB
+- NativePlanEvaluator-8.0: Current
used bytes: 272.0 MiB, peak bytes: 352.0 MiB
| \- single: Current
used bytes: 272.0 MiB, peak bytes: 352.0 MiB
| +- root: Current
used bytes: 271.7 MiB, peak bytes: 352.0 MiB
| | +- task.Gluten_Stage_0_TID_1107_VTID_8: Current
used bytes: 271.7 MiB, peak bytes: 352.0 MiB
| | | \- node.0: Current
used bytes: 271.7 MiB, peak bytes: 352.0 MiB
| | | +- op.0.0.0.TableScan: Current
used bytes: 271.7 MiB, peak bytes: 351.1 MiB
| | | \- op.0.0.0.TableScan.test-hive: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| | \- default_leaf: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- ColumnarBatches#select.1: Current
used bytes: 72.0 MiB, peak bytes: 104.0 MiB
| \- single: Current
used bytes: 72.0 MiB, peak bytes: 104.0 MiB
| +- root: Current
used bytes: 64.0 MiB, peak bytes: 104.0 MiB
| | \- default_leaf: Current
used bytes: 64.0 MiB, peak bytes: 96.0 MiB
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- IteratorMetrics.4.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- IteratorMetrics.4: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- single: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| +- root: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| | \- default_leaf: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- ColumnarBatches#offload.1.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- ColumnarBatches#offload.1: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- single: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- VeloxColumnarBatches#toVeloxBatch.1.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 2.4 MiB
+- NativePlanEvaluator-8.0.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 105.6 MiB
+- VeloxColumnarBatches#compose.1.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- VeloxColumnarBatches#toVeloxBatch.1: Current
used bytes: 0.0 B, peak bytes: 8.0 MiB
| \- single: Current
used bytes: 0.0 B, peak bytes: 8.0 MiB
| +- root: Current
used bytes: 0.0 B, peak bytes: 1024.0 KiB
| | \- default_leaf: Current
used bytes: 0.0 B, peak bytes: 48.0 KiB
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
+- ColumnarBatches#select.1.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 31.2 MiB
+- VeloxColumnarBatches#compose.1: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- single: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| +- root: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| | \- default_leaf: Current
used bytes: 0.0 B, peak bytes: 0.0 B
| \- gluten::MemoryAllocator: Current
used bytes: 0.0 B, peak bytes: 0.0 B
\- NativePlanEvaluator-9.0.OverAcquire.0: Current
used bytes: 0.0 B, peak bytes: 360.0 MiB
at
org.apache.gluten.memory.memtarget.ThrowOnOomMemoryTarget.borrow(ThrowOnOomMemoryTarget.java:105)
at
org.apache.gluten.memory.arrow.alloc.ManagedAllocationListener.onPreAllocation(ManagedAllocationListener.java:61)
at
org.apache.gluten.shaded.org.apache.arrow.memory.BaseAllocator.buffer(BaseAllocator.java:300)
at
org.apache.gluten.shaded.org.apache.arrow.memory.RootAllocator.buffer(RootAllocator.java:29)
at
org.apache.gluten.shaded.org.apache.arrow.memory.BaseAllocator.buffer(BaseAllocator.java:280)
at
org.apache.gluten.shaded.org.apache.arrow.memory.RootAllocator.buffer(RootAllocator.java:29)
at
org.apache.gluten.shaded.org.apache.arrow.vector.BaseVariableWidthVector.reallocDataBuffer(BaseVariableWidthVector.java:544)
at
org.apache.gluten.shaded.org.apache.arrow.vector.BaseVariableWidthVector.handleSafe(BaseVariableWidthVector.java:1304)
at
org.apache.gluten.shaded.org.apache.arrow.vector.BaseVariableWidthVector.setSafe(BaseVariableWidthVector.java:1101)
at
org.apache.gluten.vectorized.ArrowWritableColumnVector$StringWriter.setBytes(ArrowWritableColumnVector.java:1786)
at
org.apache.gluten.vectorized.ArrowWritableColumnVector.putBytes(ArrowWritableColumnVector.java:456)
at
org.apache.gluten.vectorized.ArrowColumnarRow.setUTF8String(ArrowColumnarRow.java:313)
at
org.apache.gluten.expression.InterpretedArrowProjection.$anonfun$getStringWriter$1(InterpretedArrowProjection.scala:62)
at
org.apache.gluten.expression.InterpretedArrowProjection.$anonfun$getStringWriter$1$adapted(InterpretedArrowProjection.scala:62)
at
org.apache.gluten.expression.InterpretedArrowProjection.$anonfun$fieldWriters$3(InterpretedArrowProjection.scala:79)
at
org.apache.gluten.expression.InterpretedArrowProjection.$anonfun$fieldWriters$3$adapted(InterpretedArrowProjection.scala:74)
at
org.apache.gluten.expression.InterpretedArrowProjection.apply(InterpretedArrowProjection.scala:94)
at
org.apache.gluten.expression.InterpretedArrowProjection.apply(InterpretedArrowProjection.scala:35)
at
org.apache.gluten.execution.ColumnarPartialProjectExec.$anonfun$getProjectedBatchArrow$3(ColumnarPartialProjectExec.scala:248)
at
org.apache.gluten.execution.ColumnarPartialProjectExec.$anonfun$getProjectedBatchArrow$3$adapted(ColumnarPartialProjectExec.scala:246)
at scala.collection.immutable.Range.foreach(Range.scala:158)
at
org.apache.gluten.execution.ColumnarPartialProjectExec.org$apache$gluten$execution$ColumnarPartialProjectExec$$getProjectedBatchArrow(ColumnarPartialProjectExec.scala:246)
at
org.apache.gluten.execution.ColumnarPartialProjectExec$$anon$1.next(ColumnarPartialProjectExec.scala:191)
at
org.apache.gluten.execution.ColumnarPartialProjectExec$$anon$1.next(ColumnarPartialProjectExec.scala:180)
at scala.collection.Iterator$$anon$10.next(Iterator.scala:461)
at
scala.collection.TraversableOnce$FlattenOps$$anon$2.hasNext(TraversableOnce.scala:521)
at
org.apache.gluten.iterator.IteratorsV1$InvocationFlowProtection.hasNext(IteratorsV1.scala:159)
at
org.apache.gluten.iterator.IteratorsV1$PayloadCloser.hasNext(IteratorsV1.scala:37)
at
scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:32)
at
org.apache.gluten.vectorized.ColumnarBatchInIterator.hasNext(ColumnarBatchInIterator.java:36)
at
org.apache.gluten.vectorized.ColumnarBatchOutIterator.nativeHasNext(Native
Method)
at
org.apache.gluten.vectorized.ColumnarBatchOutIterator.hasNext0(ColumnarBatchOutIterator.java:57)
at
org.apache.gluten.iterator.ClosableIterator.hasNext(ClosableIterator.java:39)
at
scala.collection.convert.Wrappers$JIteratorWrapper.hasNext(Wrappers.scala:45)
at
org.apache.gluten.iterator.IteratorsV1$InvocationFlowProtection.hasNext(IteratorsV1.scala:159)
at
org.apache.gluten.iterator.IteratorsV1$IteratorCompleter.hasNext(IteratorsV1.scala:71)
at
org.apache.gluten.iterator.IteratorsV1$PayloadCloser.hasNext(IteratorsV1.scala:37)
at
org.apache.gluten.iterator.IteratorsV1$LifeTimeAccumulator.hasNext(IteratorsV1.scala:100)
at scala.collection.Iterator.isEmpty(Iterator.scala:387)
at scala.collection.Iterator.isEmpty$(Iterator.scala:387)
at
org.apache.gluten.iterator.IteratorsV1$LifeTimeAccumulator.isEmpty(IteratorsV1.scala:90)
at
org.apache.gluten.execution.VeloxColumnarToRowExec$.toRowIterator(VeloxColumnarToRowExec.scala:122)
at
org.apache.gluten.execution.VeloxColumnarToRowExec.$anonfun$doExecuteInternal$1(VeloxColumnarToRowExec.scala:78)
at org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2(RDD.scala:870)
at
org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2$adapted(RDD.scala:870)
at
org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:380)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:344)
at
org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:380)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:344)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:131)
at
org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:505)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1532)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:508)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
And then the memory leak log is printed
```java
E20250630 10:34:10.668493 1677448 MemoryPool.cpp:442] [MEM] Memory leak
(Used memory): Memory Pool[default_leaf LEAF root[root] parent[root] MALLOC
track-usage thread-safe]<unlimited max capacity capacity 72.00MB used 64.01MB
available 7.99MB reservation [used 64.01MB, reserved 72.00MB, min 0B] counters
[allocs 36, frees 34, reserves 0, releases 0, collisions 0])>
E20250630 10:34:10.668634 1677448 Exceptions.h:66] Line:
/hui.an/sourcecode/gluten/cpp/velox/memory/VeloxMemoryManager.cc:102,
Function:removePool, Expression: pool->reservedBytes() == 0 (75497472 vs. 0),
Source: RUNTIME, ErrorCode: INVALID_STATE
terminate called after throwing an instance of
'facebook::velox::VeloxRuntimeError'
what(): Exception: VeloxRuntimeError
Error Source: RUNTIME
Error Code: INVALID_STATE
Reason: (75497472 vs. 0)
Retriable: False
Expression: pool->reservedBytes() == 0
Function: removePool
File: /hui.an/sourcecode/gluten/cpp/velox/memory/VeloxMemoryManager.cc
Line: 102
Stack trace:
# 0 _ZN8facebook5velox7process10StackTraceC1Ei
# 1
_ZN8facebook5velox14VeloxExceptionC1EPKcmS3_St17basic_string_viewIcSt11char_traitsIcEES7_S7_S7_bNS1_4TypeES7_
# 2
_ZN8facebook5velox6detail14veloxCheckFailINS0_17VeloxRuntimeErrorERKSsEEvRKNS1_18VeloxCheckFailArgsET0_
# 3
_ZN6gluten20ListenableArbitrator10removePoolEPN8facebook5velox6memory10MemoryPoolE
# 4 _ZN8facebook5velox6memory13MemoryManager8dropPoolEPNS1_10MemoryPoolE
# 5 _ZN8facebook5velox6memory14MemoryPoolImplD2Ev
# 6 _ZN6gluten18VeloxMemoryManagerD1Ev
# 7 _ZN6gluten18VeloxMemoryManagerD0Ev
# 8 _ZN6gluten13MemoryManager7releaseEPS0_
# 9 Java_org_apache_gluten_memory_NativeMemoryManagerJniWrapper_release
# 10 0x00007fc50d018607
```
Looks the memory not released is exactly the same as
`ColumnarBatches#select.1`, is there a memory leak here?
### Gluten version
Gluten-1.3
### Spark version
Spark-3.2.x
### Spark configurations
_No response_
### System information
_No response_
### Relevant logs
```bash
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]