cloud-fan opened a new pull request, #59009:
URL: https://github.com/apache/spark/pull/59009

   ### What changes were proposed in this pull request?
   
   Restore the pointer array lazily when `BytesToBytesMap.reset()` fails to 
allocate its replacement array. Keep the map's empty-state bookkeeping 
consistent before reset-time allocation and distinguish a failed reset from 
terminal `free()` or destructive iteration. Add regression coverage for on-heap 
and off-heap maps, including repeated allocation failures and concurrent 
`safeLookup()` callers.
   
   ### Why are the changes needed?
   
   `reset()` frees the current pointer array before allocating a new one. If 
allocation throws `SparkOutOfMemoryError`, the map retains a null array and 
stale page state. A later lookup can then throw `NullPointerException`, and an 
append could target a freed page. A transient allocation failure should either 
recover to an empty map on the next lookup or report another allocation failure.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A hash aggregation that encounters this failed-reset state can recover 
if memory becomes available; if memory remains unavailable, it reports 
`SparkOutOfMemoryError` instead of an unrelated `NullPointerException`.
   
   ### How was this patch tested?
   
   The new regression cases in `AbstractBytesToBytesMapSuite` run through both 
`BytesToBytesMapOnHeapSuite` and `BytesToBytesMapOffHeapSuite`.
   
   `git diff --check` and changed-file line length and ASCII checks passed. The 
focused SBT suites
   could not start locally because the environment cannot resolve the Maven 
hosts needed for
   `scala2-sbt-bridge:2.13.18` and `jackson-annotations:2.22`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Isaac (version not recorded), Codex (GPT-6).
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to