File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
datafusion/core/src/execution/memory_manager Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ impl MemoryManager {
330330
331331 fn max_mem_for_requesters ( & self ) -> usize {
332332 let trk_total = self . get_tracker_total ( ) ;
333- self . pool_size - trk_total
333+ self . pool_size . saturating_sub ( trk_total)
334334 }
335335
336336 /// Grow memory attempt from a consumer, return if we could grant that much to it
@@ -651,4 +651,14 @@ mod tests {
651651 let config = MemoryManagerConfig :: try_new_limit ( 100000 , 0.1 ) . unwrap ( ) ;
652652 assert_eq ! ( config. pool_size( ) , 10000 ) ;
653653 }
654+
655+ #[ tokio:: test]
656+ async fn test_memory_manager_underflow ( ) {
657+ let config = MemoryManagerConfig :: try_new_limit ( 100 , 0.5 ) . unwrap ( ) ;
658+ let manager = MemoryManager :: new ( config) ;
659+ manager. grow_tracker_usage ( 100 ) ;
660+
661+ manager. register_requester ( & MemoryConsumerId :: new ( 1 ) ) ;
662+ assert ! ( !manager. can_grow_directly( 20 , 0 ) ) ;
663+ }
654664}
You can’t perform that action at this time.
0 commit comments