Skip to content

HIVE-29703: LLAP: Parquet footer larger than alloc.max fails to cache — RuntimeException: Trying to allocate N; max is M#6584

Open
deniskuzZ wants to merge 2 commits into
apache:masterfrom
deniskuzZ:HIVE-29703
Open

HIVE-29703: LLAP: Parquet footer larger than alloc.max fails to cache — RuntimeException: Trying to allocate N; max is M#6584
deniskuzZ wants to merge 2 commits into
apache:masterfrom
deniskuzZ:HIVE-29703

Conversation

@deniskuzZ

@deniskuzZ deniskuzZ commented Jul 7, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

  • Allocate the remainder buffer with smallSize, not length.
  • Use maxAlloc <= length so a footer of exactly maxAlloc is held in one full buffer.

Why are the changes needed?

When LLAP caches a Parquet file footer whose size exceeds hive.llap.io.allocator.alloc.max, the query fails with:

  java.lang.RuntimeException: Trying to allocate 35405479; max is 33554432

Does this PR introduce any user-facing change?

No

How was this patch tested?

mvn test -pl llap-server -Dtest='TestOrcMetadataCache#testStreamFooterEqualToMaxAlloc+testStreamFooterLargerThanMaxAlloc

@deniskuzZ deniskuzZ changed the title HIVE-29703: LLAP: Parquet footer larger than alloc.max fails to cache - RuntimeException: Trying to allocate N; max is M HIVE-29703: LLAP: Parquet footer larger than alloc.max fails to cache — RuntimeException: Trying to allocate N; max is M Jul 7, 2026
@deniskuzZ deniskuzZ requested a review from Copilot July 7, 2026 09:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an LLAP MetadataCache allocation bug when caching file footers via the InputStream path, specifically for footers at or above allocator.getMaxAllocation(), preventing failures like “Trying to allocate N; max is M”.

Changes:

  • Adjust split logic to treat length == maxAlloc as a “full-buffer” case (avoid returning an empty wrapper).
  • Allocate the remainder buffer using smallSize (remainder length) instead of the full length when footers are split.
  • Refactor TestOrcMetadataCache to reuse a shared MetadataCache factory and add stream-based regression tests for == maxAlloc and > maxAlloc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
llap-server/src/java/org/apache/hadoop/hive/llap/io/metadata/MetadataCache.java Fixes buffer-splitting and remainder allocation so stream footers at/over max alloc are cached without over-allocation or empty-wrapper behavior.
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestOrcMetadataCache.java Adds regression coverage for stream footer sizes equal to and larger than MAX_ALLOC, and reduces test duplication via helper constructors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… — RuntimeException: Trying to allocate N; max is M

@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings("unchecked")
private LlapBufferOrBuffers wrapBbForFile(LlapBufferOrBuffers result,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question? If there are any exceptions like IOException or AllocatorOutOfMemoryException in readIntoCacheBuffer()/ allocateMultiple() shouldn't there be a finally block to deallocate the previously allocated buffer memory?

In readIntoCacheBuffer() there is no finally block. In allocateMultiple() there is finally block but will deallocate the current buffer not previously allocated buffer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check, but that's seems to be a diff issue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, its outside the scope of current JIRA. If it's ok , can I pick it up as separate JIRA? Will come up with a UT for this?

@deniskuzZ deniskuzZ Jul 8, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, haven't noticed your latest comment and decided to fix it here: 3bf7817

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, resolution of issue is important.

@Aggarwal-Raghav

Copy link
Copy Markdown
Contributor

LGTM +1

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants