Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][misc] Upgrade to Netty 4.1.111.Final and switch to use grpc-netty-shaded #22892

Merged
merged 11 commits into from
Jun 12, 2024

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Jun 11, 2024

Fixes #22601
Fixes #21892
Fixes #19460

Motivation

Netty 4.1.111.Final contains important fixes:

These address Broker stability when TLS with Bookkeeper V2 protocol is used between Broker and Bookies.
This will also allow removing the extra buffer copies that have been in place in Pulsar broker and Pulsar client when TLS is enabled.

public static class CopyingEncoder extends ChannelOutboundHandlerAdapter {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof ByteBufPair) {
ByteBufPair b = (ByteBufPair) msg;
// Some handlers in the pipeline will modify the bytebufs passed in to them (i.e. SslHandler).
// For these handlers, we need to pass a copy of the buffers as the source buffers may be cached
// for multiple requests.
try {
ctx.write(b.getFirst().copy(), ctx.voidPromise());
ctx.write(b.getSecond().copy(), promise);
} finally {
ReferenceCountUtil.safeRelease(b);
}
} else {
ctx.write(msg, promise);
}
}
}

This will be removed in a separate PR.

Modifications

  • Upgrade Netty to 4.1.111.Final version

Documentation

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

@lhotari
Copy link
Member Author

lhotari commented Jun 12, 2024

etcd tests break with Netty 4.1.111.Final. There's some compatibility issue.
I also tried upgrading jetcd to 0.8.2 and grpc to 1.64.0, but that didn't help.

@lhotari
Copy link
Member Author

lhotari commented Jun 12, 2024

It seems that grpc-netty dependency will have to be excluded and replaced by grpc-netty-shaded since grpc is compatible only with specific Netty versions.

@lhotari
Copy link
Member Author

lhotari commented Jun 12, 2024

Unfortunately jetcd-core isn't compatible with grpc-netty-shaded. There are conflicts with io.grpc.netty.GrpcSslContexts/io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts and io.netty.handler.ssl.SslContext/io.grpc.netty.shaded.io.netty.handler.ssl.SslContext classes. The only solution seems to be to do custom shading for jetcd-core and jetcd-test.

@lhotari
Copy link
Member Author

lhotari commented Jun 12, 2024

I found a reasonable solution by shading jetcd-core in a way where vertx is relocated and included, but grpc is switched to use grpc-netty-shaded instead of grpc-netty. stream-storage-java-client supports switching to use grpc-netty-shaded without making changes to the module.
This resolves the issue with grpc-netty and Netty 4.1.111.Final.

merlimat pushed a commit that referenced this pull request Jun 12, 2024
@merlimat
Copy link
Contributor

@lhotari There are quite a few merge conflict everywhere (except for 3.3). I'm not sure how difficult it would be to backport.

@lhotari
Copy link
Member Author

lhotari commented Jun 13, 2024

@lhotari There are quite a few merge conflict everywhere (except for 3.3). I'm not sure how difficult it would be to backport.

I'll handle the backporting. I think it's doable.

lhotari added a commit that referenced this pull request Jun 13, 2024
lhotari added a commit that referenced this pull request Jun 13, 2024
…-netty-shaded (#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)

# Conflicts:
#	distribution/server/pom.xml
lhotari added a commit that referenced this pull request Jun 13, 2024
lhotari added a commit that referenced this pull request Jun 13, 2024
- version in jetcd-core-shaded/pom.xml needs to match project version
lhotari added a commit to lhotari/pulsar that referenced this pull request Jun 14, 2024
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 25, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 27, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 27, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 27, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 1, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 1, 2024
…-netty-shaded (apache#22892)

(cherry picked from commit 75d7e55)
(cherry picked from commit a982d7b)
@inetfuture
Copy link

@lhotari Hi, I'm trying to deploy Pulsar v3.3.1 on K8s with etcd as metastore using the official Docker image, got an exception when executing bin/bookkeeper shell whatisinstanceid in pulsar-bookie-init job.

2024-09-11T16:10:48,297+0000 [main] INFO  org.apache.bookkeeper.meta.MetadataDrivers - BookKeeper metadata driver manager initialized
2024-09-11T16:10:48,408+0000 [main] ERROR org.apache.bookkeeper.bookie.BookieShell - Got an exception
java.lang.NoClassDefFoundError: io/grpc/netty/shaded/io/grpc/netty/shaded/io/netty/handler/logging/ByteBufFormat
	at org.apache.pulsar.jetcd.shaded.io.vertx.core.net.NetworkOptions.<clinit>(NetworkOptions.java:62) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at org.apache.pulsar.jetcd.shaded.io.vertx.core.VertxOptions.<init>(VertxOptions.java:143) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.vertx(ClientConnectionManager.java:223) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.defaultChannelBuilder(ClientConnectionManager.java:158) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.defaultChannelBuilder(ClientConnectionManager.java:149) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.getChannel(ClientConnectionManager.java:70) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.newStub(ClientConnectionManager.java:102) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.KVImpl.<init>(KVImpl.java:51) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientImpl.lambda$new$0(ClientImpl.java:48) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.support.MemorizingClientSupplier.get(MemorizingClientSupplier.java:37) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientImpl.getKVClient(ClientImpl.java:65) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.EtcdMetadataStore.<init>(EtcdMetadataStore.java:111) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.EtcdMetadataStoreProvider.create(EtcdMetadataStore.java:515) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.MetadataStoreFactoryImpl.newInstance(MetadataStoreFactoryImpl.java:63) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.MetadataStoreFactoryImpl.createExtended(MetadataStoreFactoryImpl.java:50) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.api.extended.MetadataStoreExtended.create(MetadataStoreExtended.java:42) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.AbstractMetadataDriver.createMetadataStore(AbstractMetadataDriver.java:117) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.AbstractMetadataDriver.initialize(AbstractMetadataDriver.java:59) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.PulsarMetadataBookieDriver.initialize(PulsarMetadataBookieDriver.java:45) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithMetadataBookieDriver(MetadataDrivers.java:356) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithRegistrationManager(MetadataDrivers.java:383) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.tools.cli.commands.bookies.InstanceIdCommand.apply(InstanceIdCommand.java:49) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell$WhatIsInstanceId.runCmd(BookieShell.java:1685) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell$MyCommand.runCmd(BookieShell.java:254) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:2674) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:2771) [org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
Caused by: java.lang.ClassNotFoundException: io.grpc.netty.shaded.io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) ~[?:?]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) ~[?:?]
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
	... 26 more

It seems to me that this PR is related, any idea how to fix this? Thanks.

@inetfuture
Copy link

I tried 3.2.4, 3.0.6 and 3.0.5, only 3.0.5 works, and I noticed this commit isnt't on 3.3.1, so I guess I'll wait and try 4.0 when it's released.

@lhotari
Copy link
Member Author

lhotari commented Sep 24, 2024

@lhotari Hi, I'm trying to deploy Pulsar v3.3.1 on K8s with etcd as metastore using the official Docker image, got an exception when executing bin/bookkeeper shell whatisinstanceid in pulsar-bookie-init job.

2024-09-11T16:10:48,297+0000 [main] INFO  org.apache.bookkeeper.meta.MetadataDrivers - BookKeeper metadata driver manager initialized
2024-09-11T16:10:48,408+0000 [main] ERROR org.apache.bookkeeper.bookie.BookieShell - Got an exception
java.lang.NoClassDefFoundError: io/grpc/netty/shaded/io/grpc/netty/shaded/io/netty/handler/logging/ByteBufFormat
	at org.apache.pulsar.jetcd.shaded.io.vertx.core.net.NetworkOptions.<clinit>(NetworkOptions.java:62) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at org.apache.pulsar.jetcd.shaded.io.vertx.core.VertxOptions.<init>(VertxOptions.java:143) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.vertx(ClientConnectionManager.java:223) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.defaultChannelBuilder(ClientConnectionManager.java:158) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.defaultChannelBuilder(ClientConnectionManager.java:149) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.getChannel(ClientConnectionManager.java:70) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientConnectionManager.newStub(ClientConnectionManager.java:102) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.KVImpl.<init>(KVImpl.java:51) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientImpl.lambda$new$0(ClientImpl.java:48) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.support.MemorizingClientSupplier.get(MemorizingClientSupplier.java:37) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at io.etcd.jetcd.impl.ClientImpl.getKVClient(ClientImpl.java:65) ~[org.apache.pulsar-jetcd-core-shaded-3.3.1-shaded.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.EtcdMetadataStore.<init>(EtcdMetadataStore.java:111) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.EtcdMetadataStoreProvider.create(EtcdMetadataStore.java:515) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.MetadataStoreFactoryImpl.newInstance(MetadataStoreFactoryImpl.java:63) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.impl.MetadataStoreFactoryImpl.createExtended(MetadataStoreFactoryImpl.java:50) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.api.extended.MetadataStoreExtended.create(MetadataStoreExtended.java:42) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.AbstractMetadataDriver.createMetadataStore(AbstractMetadataDriver.java:117) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.AbstractMetadataDriver.initialize(AbstractMetadataDriver.java:59) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.pulsar.metadata.bookkeeper.PulsarMetadataBookieDriver.initialize(PulsarMetadataBookieDriver.java:45) ~[org.apache.pulsar-pulsar-metadata-3.3.1.jar:3.3.1]
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithMetadataBookieDriver(MetadataDrivers.java:356) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithRegistrationManager(MetadataDrivers.java:383) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.tools.cli.commands.bookies.InstanceIdCommand.apply(InstanceIdCommand.java:49) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell$WhatIsInstanceId.runCmd(BookieShell.java:1685) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell$MyCommand.runCmd(BookieShell.java:254) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:2674) ~[org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
	at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:2771) [org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
Caused by: java.lang.ClassNotFoundException: io.grpc.netty.shaded.io.grpc.netty.shaded.io.netty.handler.logging.ByteBufFormat
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) ~[?:?]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) ~[?:?]
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
	... 26 more

It seems to me that this PR is related, any idea how to fix this? Thanks.

@inetfuture Please report a separate GH issue with steps to reproduce. That will be helpful in addressing this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants