dwsmith1983 opened a new issue, #7176: URL: https://github.com/apache/datafusion-comet/issues/7176
`releaseMemory` runs `used.addAndGet(-size)` ([CometTaskMemoryManager.java#L123](https://github.com/apache/datafusion-comet/blob/6a6d71c52f3452ac92ebe1c30c92c8515508f59e/spark/src/main/java/org/apache/spark/CometTaskMemoryManager.java#L123)) before `internal.releaseExecutionMemory(size, nativeMemoryConsumer)` ([L131](https://github.com/apache/datafusion-comet/blob/6a6d71c52f3452ac92ebe1c30c92c8515508f59e/spark/src/main/java/org/apache/spark/CometTaskMemoryManager.java#L131)). If Spark throws, native code gets the error and still counts the bytes as held, but `used`, and with it `NativeMemoryConsumer.getUsed`, has already dropped. The leak check at task end and Spark's spill ordering then see less than the task holds. Calling Spark first fixes it. A test can override `TaskMemoryManager.releaseExecutionMemory` to throw once and check that `getUsed` is unchanged afterwards. Found in #5613 ([review](https://github.com/apache/datafusion-comet/pull/5613#pullrequestreview-5629960270)). -- 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]
