[flink] Fix ClassNotFoundException for RoaringBitmap in shaded Flink connector JAR - #3981
[flink] Fix ClassNotFoundException for RoaringBitmap in shaded Flink connector JAR#3981pbanakar wants to merge 2 commits into
Conversation
|
@pbanakar Thanks for investigating and fixing this runtime packaging issue. At first glance, adding a third-party dependency to the shade configuration of all four version-specific connector modules looks unusual, since these modules previously only assembled Fluss artifacts. After reviewing the dependency and packaging structure again, however, I think handling RoaringBitmap at the final connector level is reasonable in this case. The version-specific modules exclude all transitive dependencies of There are two remaining issues:
Since this is the first time these version-specific connector modules explicitly include a third-party artifact in their own shade configuration, it would be helpful to get another opinion on this dependency boundary. @polyzos @wuchong , could you please take a look as well? |
|
Hi @platinumhamburg, Thank you for your support, addressed both issues, PTAL!
|
|
Thanks for the fix — verified the approach works: RoaringBitmap 1.3.0 has no transitive dependencies (the old One packaging nuance worth noting (hit the same class of issue in #3884): RoaringBitmap 1.3.0 ships as a multi-release JAR — it contains This is functionally harmless — all references are relocated to the shaded path, and the base-path <filter>
<artifact>org.roaringbitmap:RoaringBitmap</artifact>
<excludes>
<exclude>META-INF/versions/**</exclude>
</excludes>
</filter>(Excluding them is safe: the base-path class is the compatible fallback; only the Java-11-optimized variant is dropped.) Aside from that, +1 from me — and I also agree with @platinumhamburg's take on the dependency boundary: shading at the connector level keeps |
Purpose
Linked issue: close #3980
Fix
ClassNotFoundException: org.roaringbitmap.RoaringBitmapat runtime when using FlussCatalog bitmap functions introduced in FIP-37 (rb_build_agg,rb_cardinality,rb_or_agg).Brief change log
Root cause:
RoaringBitmapis declared ascompilescope influss-flink-common/pom.xml, but Maven's dependency mediation resolves it astestscope in the version-specific Flink connector modules. This happens becausefluss-flink-common:test-jaris atest-scoped dependency in those modules, and its transitiveRoaringBitmapdependency overrides thecompilescope from the main artifact. As a result, themaven-shade-pluginexcludesorg/roaringbitmap/*classes from the final shaded connector JAR.Confirmed by: ./mvnw dependency:tree -pl fluss-flink/fluss-flink-1.20 | grep roaring
→ org.roaringbitmap:RoaringBitmap:jar:1.3.0:test ← wrong scope
jar tf fluss-flink-1.20-*.jar | grep "org/roaringbitmap" → (empty) ← classes missing from JAR
Fix: Add an explicit
compile-scopeRoaringBitmapdependency influss-flink-1.18,fluss-flink-1.19,fluss-flink-1.20, andfluss-flink-2.2pom.xmlfiles to override thetestscope resolution.After fix: jar tf fluss-flink-1.20-*.jar | grep "org/roaringbitmap" → org/roaringbitmap/RoaringBitmap.class (and all other classes present)
Tests
Verified end-to-end locally on Flink 1.20:
apache/fluss-quickstart-flinkfrom main branch with fix appliedrb_build_aggandrb_cardinalityunique_visitor_countandtotal_clicksaccumulating in real time with no errorsAPI and Format
No API or storage format changes. This is a packaging fix only — 4
pom.xmlfiles modified.Documentation
No documentation changes. This fix unblocks the Real-Time User Profile quickstart tutorial (PR #2669 ) which demonstrates these functions.