Skip to content

Commit d010ce9

Browse files
authored
refactor(11523): update OOM message provided for a single failed reservation (#11771)
1 parent 70aba2b commit d010ce9

File tree

1 file changed

+14
-14
lines changed
  • datafusion/execution/src/memory_pool

1 file changed

+14
-14
lines changed

datafusion/execution/src/memory_pool/pool.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn insufficient_capacity_err(
246246
additional: usize,
247247
available: usize,
248248
) -> DataFusionError {
249-
resources_datafusion_err!("Failed to allocate additional {} bytes for {} with {} bytes already allocated - maximum available is {}", additional, reservation.registration.consumer.name, reservation.size, available)
249+
resources_datafusion_err!("Failed to allocate additional {} bytes for {} with {} bytes already allocated for this reservation - {} bytes remain available for the total pool", additional, reservation.registration.consumer.name, reservation.size, available)
250250
}
251251

252252
/// A [`MemoryPool`] that tracks the consumers that have
@@ -418,10 +418,10 @@ mod tests {
418418
assert_eq!(pool.reserved(), 4000);
419419

420420
let err = r2.try_grow(1).unwrap_err().strip_backtrace();
421-
assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated - maximum available is 0");
421+
assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated for this reservation - 0 bytes remain available for the total pool");
422422

423423
let err = r2.try_grow(1).unwrap_err().strip_backtrace();
424-
assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated - maximum available is 0");
424+
assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated for this reservation - 0 bytes remain available for the total pool");
425425

426426
r1.shrink(1990);
427427
r2.shrink(2000);
@@ -446,12 +446,12 @@ mod tests {
446446
.register(&pool);
447447

448448
let err = r3.try_grow(70).unwrap_err().strip_backtrace();
449-
assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated - maximum available is 40");
449+
assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated for this reservation - 40 bytes remain available for the total pool");
450450

451451
//Shrinking r2 to zero doesn't allow a3 to allocate more than 45
452452
r2.free();
453453
let err = r3.try_grow(70).unwrap_err().strip_backtrace();
454-
assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated - maximum available is 40");
454+
assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated for this reservation - 40 bytes remain available for the total pool");
455455

456456
// But dropping r2 does
457457
drop(r2);
@@ -464,7 +464,7 @@ mod tests {
464464

465465
let mut r4 = MemoryConsumer::new("s4").register(&pool);
466466
let err = r4.try_grow(30).unwrap_err().strip_backtrace();
467-
assert_eq!(err, "Resources exhausted: Failed to allocate additional 30 bytes for s4 with 0 bytes already allocated - maximum available is 20");
467+
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");
468468
}
469469

470470
#[test]
@@ -501,7 +501,7 @@ mod tests {
501501
// Test: reports if new reservation causes error
502502
// using the previously set sizes for other consumers
503503
let mut r5 = MemoryConsumer::new("r5").register(&pool);
504-
let expected = "Resources exhausted with top memory consumers (across reservations) are: r1 consumed 50 bytes, r3 consumed 20 bytes, r2 consumed 15 bytes. Error: Failed to allocate additional 150 bytes for r5 with 0 bytes already allocated - maximum available is 5";
504+
let expected = "Resources exhausted with top memory consumers (across reservations) are: r1 consumed 50 bytes, r3 consumed 20 bytes, r2 consumed 15 bytes. Error: Failed to allocate additional 150 bytes for r5 with 0 bytes already allocated for this reservation - 5 bytes remain available for the total pool";
505505
let res = r5.try_grow(150);
506506
assert!(
507507
matches!(
@@ -524,7 +524,7 @@ mod tests {
524524

525525
// Test: see error message when no consumers recorded yet
526526
let mut r0 = MemoryConsumer::new(same_name).register(&pool);
527-
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 0 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated - maximum available is 100";
527+
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 0 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated for this reservation - 100 bytes remain available for the total pool";
528528
let res = r0.try_grow(150);
529529
assert!(
530530
matches!(
@@ -543,7 +543,7 @@ mod tests {
543543
let mut r1 = new_consumer_same_name.clone().register(&pool);
544544
// TODO: the insufficient_capacity_err() message is per reservation, not per consumer.
545545
// a followup PR will clarify this message "0 bytes already allocated for this reservation"
546-
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 10 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated - maximum available is 90";
546+
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 10 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated for this reservation - 90 bytes remain available for the total pool";
547547
let res = r1.try_grow(150);
548548
assert!(
549549
matches!(
@@ -555,7 +555,7 @@ mod tests {
555555

556556
// Test: will accumulate size changes per consumer, not per reservation
557557
r1.grow(20);
558-
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 30 bytes. Error: Failed to allocate additional 150 bytes for foo with 20 bytes already allocated - maximum available is 70";
558+
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo consumed 30 bytes. Error: Failed to allocate additional 150 bytes for foo with 20 bytes already allocated for this reservation - 70 bytes remain available for the total pool";
559559
let res = r1.try_grow(150);
560560
assert!(
561561
matches!(
@@ -570,7 +570,7 @@ mod tests {
570570
let consumer_with_same_name_but_different_hash =
571571
MemoryConsumer::new(same_name).with_can_spill(true);
572572
let mut r2 = consumer_with_same_name_but_different_hash.register(&pool);
573-
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo(can_spill=false) consumed 30 bytes, foo(can_spill=true) consumed 0 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated - maximum available is 70";
573+
let expected = "Resources exhausted with top memory consumers (across reservations) are: foo(can_spill=false) consumed 30 bytes, foo(can_spill=true) consumed 0 bytes. Error: Failed to allocate additional 150 bytes for foo with 0 bytes already allocated for this reservation - 70 bytes remain available for the total pool";
574574
let res = r2.try_grow(150);
575575
assert!(
576576
matches!(
@@ -590,7 +590,7 @@ mod tests {
590590
let r1_consumer = MemoryConsumer::new("r1");
591591
let mut r1 = r1_consumer.clone().register(&pool);
592592
r1.grow(20);
593-
let expected = "Resources exhausted with top memory consumers (across reservations) are: r1 consumed 20 bytes, r0 consumed 10 bytes. Error: Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated - maximum available is 70";
593+
let expected = "Resources exhausted with top memory consumers (across reservations) are: r1 consumed 20 bytes, r0 consumed 10 bytes. Error: Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated for this reservation - 70 bytes remain available for the total pool";
594594
let res = r0.try_grow(150);
595595
assert!(
596596
matches!(
@@ -616,7 +616,7 @@ mod tests {
616616

617617
// Test: actual message we see is the `available is 70`. When it should be `available is 90`.
618618
// This is because the pool.shrink() does not automatically occur within the inner_pool.deregister().
619-
let expected_70_available = "Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated - maximum available is 70";
619+
let expected_70_available = "Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated for this reservation - 70 bytes remain available for the total pool";
620620
let res = r0.try_grow(150);
621621
assert!(
622622
matches!(
@@ -629,7 +629,7 @@ mod tests {
629629
// Test: the registration needs to free itself (or be dropped),
630630
// for the proper error message
631631
r1.free();
632-
let expected_90_available = "Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated - maximum available is 90";
632+
let expected_90_available = "Failed to allocate additional 150 bytes for r0 with 10 bytes already allocated for this reservation - 90 bytes remain available for the total pool";
633633
let res = r0.try_grow(150);
634634
assert!(
635635
matches!(

0 commit comments

Comments
 (0)