[GLUTEN-12564][CORE] Exclude DefaultAllocationManagerFactory from gluten-package shade bundle#12565
Open
wangyum wants to merge 1 commit into
Open
[GLUTEN-12564][CORE] Exclude DefaultAllocationManagerFactory from gluten-package shade bundle#12565wangyum wants to merge 1 commit into
wangyum wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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.classfrom the shade bundle for the CORE,unsafe/, andnetty/Arrow class paths. - Add inline documentation explaining the Arrow 16.0.0+
CheckAllocatorbehavior and why the exclusion is necessary.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
force-pushed
the
fix-arrow-allocation-manager-shading
branch
from
July 20, 2026 08:06
813eb39 to
57f1b76
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Exclude
DefaultAllocationManagerFactory.class(in all three known Arrow locations — CORE path,unsafe/subpath,netty/subpath) from thegluten-package.jarshade 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 upstreamarrow-memory-unsafe/arrow-memory-nettyjar declared as agluten-arrowdependency.Starting with Arrow 16.0.0,
CheckAllocator.check()inspects the URL ofDefaultAllocationManagerFactory.classand throwsIllegalStateException: Unknown allocation manager type to inferwhen the URL does not containmemory-core,memory-unsafe, ormemory-netty. When the class is loaded from insidegluten-package.jarthe URL matches none of these patterns (especially for Arrow <= 15.x where the class lives at the CORE pathorg/apache/arrow/memory/DefaultAllocationManagerFactory.class).This is currently silent on upstream CI because:
CheckAllocatorpredates the URL check.spark-4.0profile overridesarrow.versionto 18.1.0 sogluten-packagebundles theunsafe/-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'sspark-3.5profile still usesarrow.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
FACTORYfield providing anAllocationManager.Factory). The only behavioral change is that Gluten stops forcing the unsafe allocator and lets Arrow's own default selection apply (which isnettyperDefaultAllocationManagerOption.java:80).How was this patch tested?
gluten-package.jar.arrow-memory-netty-*.jar/arrow-memory-unsafe-*.jaralways provides aDefaultAllocationManagerFactory.classwhose URL matchesCheckAllocator's pattern (for Arrow >= 16.x). For Arrow <= 15.x theCheckAllocatordoes not perform URL inspection, so the fix is a no-op there.gluten-utsuites continue to pass (no source-code change).Closes #12564.
Was this patch authored or co-authored using generative AI tooling?
No