Zoltán Borók-Nagy created IMPALA-15862:
------------------------------------------

             Summary: Initial reservation can fail at the process soft limit 
while GC leaves free buffers cached
                 Key: IMPALA-15862
                 URL: https://issues.apache.org/jira/browse/IMPALA-15862
             Project: IMPALA
          Issue Type: Bug
          Components: Backend
            Reporter: Zoltán Borók-Nagy


When a query claims its initial reservation, 
ReservationTracker::IncreaseReservationInternalLocked() grants the increase on 
the buffer pool's root tracker before it calls MemTracker::TryConsume() for the 
query (be/src/runtime/bufferpool/reservation-tracker.cc). That check uses the 
process soft limit (0.9 x mem_limit), because the query-level 
ReservationTracker is created with the default MemLimit::SOFT and is the only 
link that checks a limit. InitialReservations asks for MemLimit::HARD, since 
IMPALA-7297 meant soft limits not to apply to the initial reservation, but that 
mode is never used (be/src/runtime/initial-reservations.cc). Over the soft 
limit, MemTracker::GcMemory() runs the buffer pool's GC function 
(be/src/runtime/exec-env.cc), which frees cached buffers only above 
buffer-pool.reserved. "reserved" already includes the increase being checked, 
so a claim at least as large as the buffer pool's allocated memory makes the GC 
free nothing, and the query fails with MINIMUM_RESERVATION_UNAVAILABLE.

Example on master: TPC-DS SF10000 q14_1 with COMPUTE_PROCESSING_COST=true and 
MAX_FRAGMENT_INSTANCES_PER_NODE=8 on 12 executors, mem_limit=40G, run 3 times 
back to back. Iterations 1 and 2 succeed (702 s and 678 s). Before iteration 3, 
every daemon reports no query executing and buffer-pool.reserved = 0, so unlike 
in IMPALA-15678 no state of the previous query remains. Iteration 3 fails after 
5.9 s on the coordinator: "Failed to get minimum memory reservation of 27.48 GB 
... Memory left in process limit: 30.66 GB". 9.34 GB used + 27.48 GB = 36.82 GB 
is over the 36 GB soft limit but under the 40 GB hard limit. 
mem-tracker.process.num-gcs went from 0 to 1 with bytes-freed-by-last-gc = 0, 
although freeing 0.82 GB would have been enough, and 10 s later the idle daemon 
still cached 4.02 GB of free buffers. Iteration 2 got the same claim on the 
same daemon without a GC, so the outcome depends on the daemon's memory state 
when the claim arrives.

Proposal: apply MemLimit::HARD to the initial reservation, as IMPALA-7297 
intended; here 36.82 GB fits under the 40 GB hard limit. Separately, do not let 
the in-flight increase hide cached buffers from the GC: check the query's 
MemTracker before granting the increase on the parent trackers, rolling back on 
failure, or exclude the increase from "reserved" in the GC function.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to