viirya commented on code in PR #11218: URL: https://github.com/apache/datafusion/pull/11218#discussion_r1674703720
########## datafusion/physical-plan/src/joins/sort_merge_join.rs: ########## @@ -867,12 +951,17 @@ impl SMJStream { while !self.buffered_data.batches.is_empty() { let head_batch = self.buffered_data.head_batch(); // If the head batch is fully processed, dequeue it and produce output of it. - if head_batch.range.end == head_batch.batch.num_rows() { + if head_batch.range.end == head_batch.num_rows { self.freeze_dequeuing_buffered()?; if let Some(buffered_batch) = self.buffered_data.batches.pop_front() { - self.reservation.shrink(buffered_batch.size_estimation); + // Shrink mem usage for non spilled batches only + if buffered_batch.spill_file.is_none() { + self.reservation + .try_shrink(buffered_batch.size_estimation) + .unwrap_or(()); Review Comment: Why we need to change to `try_shrink` here? If the batch uses some memory from the pool, the pool should have the size of the batch allocated. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org