GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][misc] Unable to connect an etcd metastore with recent releases due to jetc-core sharding problem by Shawyeok · Pull Request #23604 · apache/pulsar

Conversation

@Shawyeok

@Shawyeok Shawyeok commented Nov 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #23513

With recent pulsar releases, it raise NoClassDefFoundError if setup with a etcd metadata.

docker run -it --rm apachepulsar/pulsar:4.0.0 bin/pulsar standalone --metadata-url etcd:http://a-etcd:2379
docker run -it --rm apachepulsar/pulsar:3.0.6 bin/pulsar standalone --metadata-url etcd:http://a-etcd:2379

Motivation

The jetcd-core-shaded module was introduced in #22892 to address the compatibility issues between jetcd-core’s grpc-java dependency and Netty. You can find more details here and in the grpc-java documentation.

Currently, we use unpack-shaded-jar execution unpacks the shaded jar produced by maven-shade-plugin:shade into the jetcd-core-shaded/target/classes directory. However, the classes in this directory conflict with its dependencies. If the maven-shade-plugin:shade runs again without cleaning this directory, it can produce an incorrect shaded jar. You can replicate and verify this issue with the following commands:

# Step 1: Clean the build directory
mvn clean

# Step 2: Perform an install and unpack the shaded jar into a directory.
# Verify the import statement for `io.netty.handler.logging.ByteBufFormat` in 
# `org/apache/pulsar/jetcd/shaded/io/vertx/core/net/NetClientOptions.class`. 
# The correct import should be: 
# `import io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat;`.
mvn install
unzip $M2_REPO/org/apache/pulsar/jetcd-core-shaded/4.1.0-SNAPSHOT/jetcd-core-shaded-4.1.0-SNAPSHOT-shaded.jar \
  -d jetcd-core-shaded/target/first-classes

# Step 3: Run the install command again without cleaning.
# The unpacked jar from the previous step will persist in `jetcd-core-shaded/target/classes`. 
# Unpack the shaded jar into a different directory (e.g., second-classes) and check the import.
# The incorrect import will be: 
# `import io.grpc.netty.shaded.io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat;`.
mvn install
unzip $M2_REPO/org/apache/pulsar/jetcd-core-shaded/4.1.0-SNAPSHOT/jetcd-core-shaded-4.1.0-SNAPSHOT-shaded.jar \
  -d jetcd-core-shaded/target/second-classes

# Step 4: Use IntelliJ IDEA's "Compare Directories" tool to compare the `first-classes` 
# and `second-classes` directories. The differences in imports should become apparent.

A simpler solution is to remove the configurations related to attach and unpack. IntelliJ IDEA assumes the shaded jar path is target/${artifactId}-${version}.jar. However, in Pulsar’s build system, the finalName is set to just ${artifactId} in the parent pom.xml. While I’m unsure of the reasoning behind this setup, we can override the finalName in jetcd-core-shaded/pom.xml. This is the approach I’ve taken in this patch.

Verifying this change

This issue typically cannot be detected by CI tests, as CI environments always run in a clean workspace. To address this, we could refine our release guidelines to include a step for cleaning the workspace before deploying artifacts. Additionally, incorporating automated checks into the release validation process could help catch such issues early.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: Shawyeok#18

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Shawyeok added 2 commits November 12, 2024 00:53
@Shawyeok
Fix jetcd-core-shaded issue
f9c3b40
@Shawyeok
Change jetcd-core-shaded build finalName
b433b87
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Nov 15, 2024
@Shawyeok Shawyeok mentioned this pull request Nov 15, 2024
[Bug] NoClassDefFoundError: io/grpc/netty/shaded/io/grpc/netty/shaded/io/netty/handler/logging/ByteBufFormat #23513
Closed
2 of 3 tasks
lhotari
lhotari reviewed Nov 15, 2024
View reviewed changes
Comment thread jetcd-core-shaded/pom.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@lhotari

lhotari commented Nov 15, 2024

Copy link
Copy Markdown
Member

A simpler solution is to remove the configurations related to attach and unpack. IntelliJ IDEA assumes the shaded jar path is target/${artifactId}-${version}.jar. However, in Pulsar’s build system, the finalName is set to just ${artifactId} in the parent pom.xml. While I’m unsure of the reasoning behind this setup, we can override the finalName in jetcd-core-shaded/pom.xml. This is the approach I’ve taken in this patch.

Thank you, @Shawyeok! Great work. How did you find out that IntelliJ expects this format? Could we remove overriding of finalName in pom.xml so that we'd use the default everywhere? It seems that the finalName was overridden already in the initial commit of Pulsar.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari
Remove unnecessary commented out dependency
8cb145a
lhotari
lhotari approved these changes Nov 15, 2024
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lhotari

lhotari commented Nov 15, 2024

Copy link
Copy Markdown
Member

@Shawyeok Please submit a similar change to BookKeeper since there's a similar solution to shade jetcd-core in metadata-drivers/jetcd-core-shaded/pom.xml.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari lhotari added the area/metadata label Nov 15, 2024
@lhotari lhotari added this to the 4.1.0 milestone Nov 15, 2024
@lhotari lhotari added release/3.3.3 release/4.0.1 release/3.0.8 labels Nov 15, 2024
@Shawyeok

Shawyeok commented Nov 15, 2024

Copy link
Copy Markdown
Contributor Author

@lhotari

How did you find out that IntelliJ expects this format?

There is a silent error in the pulsar-metadata module dependencies, which I discovered by coincidence.

image_1731639655772_0

image

Could we remove overriding of finalName in pom.xml so that we'd use the default everywhere? It seems that the finalName was overridden already in the initial commit of Pulsar.

I tried once, but other configurations depend on the current finalName setting, such as:

pulsar/distribution/server/src/assemble/bin.xml

Line 89 in 81385c5

<source>${basedir}/../../pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar</source>

I wasn’t sure what was beneath the surface :-) , so I opted for a conservative approach.

lhotari reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Shawyeok

Shawyeok commented Nov 15, 2024

Copy link
Copy Markdown
Contributor Author

@Shawyeok Please submit a similar change to BookKeeper since there's a similar solution to shade jetcd-core in metadata-drivers/jetcd-core-shaded/pom.xml.

Sure, will do it tomorrow.

lhotari reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Nov 16, 2024
Fix potential jetcd core shading problem Shawyeok/bookkeeper#3
Closed
Fix potential jetcd-core shading problem apache/bookkeeper#4526
Merged
@codecov-commenter

codecov-commenter commented Nov 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.35%. Comparing base (bbc6224) to head (8cb145a).
Report is 1132 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23604      +/-   ##
============================================
+ Coverage     73.57%   74.35%   +0.78%     
- Complexity    32624    34443    +1819     
============================================
  Files          1877     1944      +67     
  Lines        139502   147127    +7625     
  Branches      15299    16225     +926     
============================================
+ Hits         102638   109398    +6760     
- Misses        28908    29293     +385     
- Partials       7956     8436     +480     
Flag Coverage Δ
inttests 27.57% <ø> (+2.98%) ⬆️
systests 24.40% <ø> (+0.08%) ⬆️
unittests 73.72% <ø> (+0.87%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 656 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari
lhotari merged commit 89ccb73 into apache:master Nov 16, 2024
hezhangjian pushed a commit to apache/bookkeeper that referenced this pull request Nov 18, 2024
@Shawyeok
Fix potential jetcd-core shading problem (#4526)
f119d07
### Motivation

There is a potential jar shading issue introduced in #4426 that causes `NoClassDefFoundError` when connecting to an etcd metadata store.

The `jetcd-core-shaded` module was introduced in #4426 to address the compatibility issues between jetcd-core’s grpc-java dependency and Netty. You can find more details [here][1] and in the [grpc-java documentation][2].

[1]: #4426 (comment)
[2]: https://github.com/grpc/grpc-java/blob/master/SECURITY.md#netty

Currently, we use `unpack-shaded-jar` execution unpacks the shaded jar produced by `maven-shade-plugin:shade` into the `jetcd-core-shaded/target/classes` directory. However, the classes in this directory conflict with its dependencies. If the `maven-shade-plugin:shade` runs again without cleaning this directory, it can produce an incorrect shaded jar. You can replicate and verify this issue with the following commands:
```shell
# Step 1: Clean the build directory
mvn clean

# Step 2: Perform an install and unpack the shaded jar into a directory.
# Verify the import statement for `io.netty.handler.logging.ByteBufFormat` in 
# `org/apache/pulsar/jetcd/shaded/io/vertx/core/net/NetClientOptions.class`. 
# The correct import should be: 
# `import io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat;`.
mvn install
unzip $M2_REPO/org/apache/bookkeeper/metadata/drivers/jetcd-core-shaded/4.18.0-SNAPSHOT/jetcd-core-shaded-4.18.0-SNAPSHOT-shaded.jar \
  -d metadata-drivers/jetcd-core-shaded/target/first-classes

# Step 3: Run the install command again without cleaning.
# The unpacked jar from the previous step will persist in `target/classes`. 
# Unpack the shaded jar into a different directory (e.g., second-classes) and check the import.
# The incorrect import will be: 
# `import io.grpc.netty.shaded.io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat;`.
mvn install
unzip $M2_REPO/org/apache/bookkeeper/metadata/drivers/jetcd-core-shaded/4.18.0-SNAPSHOT/jetcd-core-shaded-4.18.0-SNAPSHOT-shaded.jar \
  -d metadata-drivers/jetcd-core-shaded/target/second-classes

# Step 4: Use IntelliJ IDEA's "Compare Directories" tool to compare the `first-classes` 
# and `second-classes` directories. The differences in imports should become apparent.
```

We can remove the attach and unpack configurations, and it should work fine.

This issue has already been [reported][3] in apache/pulsar, and a similar [patch][patch] has addressed it.

[3]: apache/pulsar#23513
[patch]: apache/pulsar#23604
lhotari added a commit that referenced this pull request Nov 18, 2024
@Shawyeok @lhotari
[fix][misc] Unable to connect an etcd metastore with recent releases …
23f1ef0
…due to jetc-core sharding problem (#23604)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 89ccb73)
lhotari added a commit that referenced this pull request Nov 18, 2024
@Shawyeok @lhotari
[fix][misc] Unable to connect an etcd metastore with recent releases …
8f93f54
…due to jetc-core sharding problem (#23604)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 89ccb73)
lhotari added a commit that referenced this pull request Nov 18, 2024
@Shawyeok @lhotari
[fix][misc] Unable to connect an etcd metastore with recent releases …
73e06ff
…due to jetc-core sharding problem (#23604)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 89ccb73)
@lhotari lhotari added cherry-picked/branch-4.0 cherry-picked/branch-3.3 cherry-picked/branch-3.0 labels Nov 18, 2024
@Technoboy- Technoboy- assigned Shawyeok Nov 20, 2024
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 20, 2024
@Shawyeok @lhotari @nikhil-ctds
[fix][misc] Unable to connect an etcd metastore with recent releases …
a17aed7
…due to jetc-core sharding problem (apache#23604)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 89ccb73)
(cherry picked from commit 23f1ef0)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 21, 2024
@Shawyeok @lhotari @srinath-ctds
[fix][misc] Unable to connect an etcd metastore with recent releases …
969b274
…due to jetc-core sharding problem (apache#23604)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 89ccb73)
(cherry picked from commit 23f1ef0)
@Shawyeok Shawyeok mentioned this pull request Nov 26, 2024
[fix][misc] Class conflict during jetcd-core-shaded shading process #23641
Merged
1 of 14 tasks
@lhotari lhotari mentioned this pull request Jan 13, 2025
[improve][misc] Upgrade to Netty 4.1.111.Final and switch to use grpc-netty-shaded #22892
Merged
1 of 4 tasks
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 2025
@Shawyeok @lhotari hanmz
[fix][misc] Unable to connect an etcd metastore with recent releases …
26da222
…due to jetc-core sharding problem (apache#23604)

Co-authored-by: Lari Hotari <[email protected]>
@merlimat merlimat mentioned this pull request Oct 24, 2026
[Bug] [Regression] etcd mTLS doesn't work on 3.3.1 #23160
Open
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Shawyeok Shawyeok

Labels

area/metadata cherry-picked/branch-3.0 cherry-picked/branch-3.3 cherry-picked/branch-4.0 doc-not-needed Your PR changes do not impact docs release/3.0.8 release/3.3.3 release/4.0.1

Projects

None yet

Milestone

4.1.0

Development

Successfully merging this pull request may close these issues.

[Bug] NoClassDefFoundError: io/grpc/netty/shaded/io/grpc/netty/shaded/io/netty/handler/logging/ByteBufFormat

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Shawyeok @lhotari @codecov-commenter
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.