Skip to content

[GLUTEN-12564][CORE] Exclude DefaultAllocationManagerFactory from gluten-package shade bundle#12565

Open
wangyum wants to merge 1 commit into
apache:mainfrom
wangyum:fix-arrow-allocation-manager-shading
Open

[GLUTEN-12564][CORE] Exclude DefaultAllocationManagerFactory from gluten-package shade bundle#12565
wangyum wants to merge 1 commit into
apache:mainfrom
wangyum:fix-arrow-allocation-manager-shading

Conversation

@wangyum

@wangyum wangyum commented Jul 19, 2026

Copy link
Copy Markdown
Member

What changes are proposed in this pull request?

Exclude DefaultAllocationManagerFactory.class (in all three known Arrow locations — CORE path, unsafe/ subpath, netty/ subpath) from the gluten-package.jar shade bundle.

The class is bundled today because the shade plugin's relocation excludes org.apache.arrow.memory.** from relocation but still includes the class files in the bundle. The class is redundant — the same class is always available on the runtime classpath via the upstream arrow-memory-unsafe / arrow-memory-netty jar declared as a gluten-arrow dependency.

Starting with Arrow 16.0.0, CheckAllocator.check() inspects the URL of DefaultAllocationManagerFactory.class and throws IllegalStateException: Unknown allocation manager type to infer when the URL does not contain memory-core, memory-unsafe, or memory-netty. When the class is loaded from inside gluten-package.jar the URL matches none of these patterns (especially for Arrow <= 15.x where the class lives at the CORE path org/apache/arrow/memory/DefaultAllocationManagerFactory.class).

This is currently silent on upstream CI because:

  • Spark 3.3/3.4/3.5 community uses Arrow 12.0.1 whose CheckAllocator predates the URL check.
  • Spark 4.0/4.1 uses Arrow 18.1.0; the spark-4.0 profile overrides arrow.version to 18.1.0 so gluten-package bundles the unsafe/-subpath class whose URL contains /org/apache/arrow/memory/unsafe/ and matches.

But the bug manifests whenever a Spark distribution ships Arrow >= 16.0.0 while Gluten is built with arrow.version <= 15.x — e.g. a downstream Spark 3.5 fork that upgrades Arrow from 12.0.1 to 18.3.0 while Gluten's spark-3.5 profile still uses arrow.version=15.0.0. Removing the duplicate class lets the classloader find the upstream Arrow jar, whose URL contains a recognized substring.

The class is functionally identical (same FACTORY field providing an AllocationManager.Factory). The only behavioral change is that Gluten stops forcing the unsafe allocator and lets Arrow's own default selection apply (which is netty per DefaultAllocationManagerOption.java:80).

How was this patch tested?

  • Verified the bundled jar before/after the change confirms the class is no longer present in gluten-package.jar.
  • Verified the upstream arrow-memory-netty-*.jar / arrow-memory-unsafe-*.jar always provides a DefaultAllocationManagerFactory.class whose URL matches CheckAllocator's pattern (for Arrow >= 16.x). For Arrow <= 15.x the CheckAllocator does not perform URL inspection, so the fix is a no-op there.
  • Existing gluten-ut suites continue to pass (no source-code change).

Closes #12564.


Was this patch authored or co-authored using generative AI tooling?

No

Copilot AI review requested due to automatic review settings July 19, 2026 14:45
@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 19, 2026

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

This PR updates the gluten-package shaded bundle configuration to exclude DefaultAllocationManagerFactory.class from being packaged into gluten-package.jar, preventing Arrow 16.0.0+ CheckAllocator URL-based inference failures when Spark ships a newer Arrow version than Gluten’s build-time Arrow.

Changes:

  • Exclude DefaultAllocationManagerFactory.class from the shade bundle for the CORE, unsafe/, and netty/ Arrow class paths.
  • Add inline documentation explaining the Arrow 16.0.0+ CheckAllocator behavior and why the exclusion is necessary.

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

Comment thread package/pom.xml
Comment on lines +173 to +177
patterns (in particular for Arrow <= 15.x where the class
lives at org/apache/arrow/memory/DefaultAllocationManager
Factory.class), breaking allocator initialization whenever
the runtime Arrow version is >= 16.0.0 (e.g. Spark
distributions that ship a newer Arrow than Gluten's
…ten-package shade bundle

The shaded gluten-package.jar bundles DefaultAllocationManagerFactory.class
(both the CORE path in Arrow <= 15.x and the unsafe/netty subpaths in
Arrow >= 16.x) because the shade relocation excludes
org.apache.arrow.memory.** from relocation but still keeps the class
files in the bundle. The class is redundant — it always exists in the
upstream arrow-memory-unsafe / arrow-memory-netty jar that is on the
runtime classpath.

Starting with Arrow 16.0.0, CheckAllocator.check() inspects the URL of
DefaultAllocationManagerFactory.class and throws
"IllegalStateException: Unknown allocation manager type to infer"
when the URL does not contain "memory-core", "memory-unsafe", or
"memory-netty". When the class is loaded from inside
gluten-package.jar the URL matches none of these patterns (in
particular for Arrow <= 15.x where the class lives at the CORE path
org/apache/arrow/memory/DefaultAllocationManagerFactory.class).

This is currently silent on upstream CI because:
  - Spark 3.3/3.4/3.5 community uses Arrow 12.0.1 whose CheckAllocator
    predates the URL check.
  - Spark 4.0/4.1 uses Arrow 18.1.0; the spark-4.0 profile overrides
    arrow.version to 18.1.0 so gluten-package bundles the unsafe/-
    subpath class whose URL contains "/org/apache/arrow/memory/unsafe/"
    and matches the URL pattern.

But the bug manifests whenever a Spark distribution ships Arrow >=
16.0.0 while Gluten is built with arrow.version <= 15.x (e.g. a
downstream Spark 3.5 fork that upgrades Arrow from 12.0.1 to 18.3.0
while Gluten's spark-3.5 profile still uses arrow.version=15.0.0).

Fix: exclude the three known DefaultAllocationManagerFactory class
locations from the shaded bundle so the classloader always finds the
class in the upstream arrow-memory-*.jar, whose URL contains a
recognized substring. The class is functionally identical (same FACTORY
field providing an AllocationManager.Factory); the only behavioral
change is that Gluten stops forcing the unsafe allocator and lets
Arrow's own default selection apply (which is netty per
DefaultAllocationManagerOption.java:80).

Closes apache#12564.
@wangyum
wangyum force-pushed the fix-arrow-allocation-manager-shading branch from 813eb39 to 57f1b76 Compare July 20, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gluten-package.jar bundles duplicate DefaultAllocationManagerFactory that breaks Arrow 16.0.0+ CheckAllocator

2 participants