Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for fair spill pool with split reservations #12170

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions datafusion/execution/src/memory_pool/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,26 @@ mod tests {
assert_eq!(err, "Resources exhausted: Failed to allocate additional 30 bytes for s4 with 0 bytes already allocated for this reservation - 20 bytes remain available for the total pool");
}

#[test]
fn test_fair_with_split_reservation() {
let pool = Arc::new(FairSpillPool::new(100)) as _;
let mut r1 = MemoryConsumer::new("spillable")
.with_can_spill(true)
.register(&pool);

// Allocate all available memory.
r1.try_grow(100).unwrap();

// Split the reservation in half.
let _ = r1.split(50);

// Try to grow the reservation beyond the pool size.
let err = r1.try_grow(1).unwrap_err().strip_backtrace();

// note: "100 bytes available" refers to pool size minus unspillable reservations
assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for spillable with 100 bytes already allocated for this reservation - 100 bytes remain available for the total pool");
}

#[test]
fn test_tracked_consumers_pool() {
let pool: Arc<dyn MemoryPool> = Arc::new(TrackConsumersPool::new(
Expand Down