[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 1 commit 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? |
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.