[pulsar-common] MaxMessageSize to user configuration#4063
[pulsar-common] MaxMessageSize to user configuration#4063ambition119 wants to merge 1 commit intoapache:masterfrom
Conversation
sijie
left a comment
There was a problem hiding this comment.
MaxMessageSize should be agreed between client, broker and bookie. So a better approach would be:
- adding a setting
MaxMessageSizesetting to broker configuration. - introduce a mechanism between client and broker to fetch some broker configurations when the client establishes a connection to broker. in this case, broker can return the MaxMessageSize it supports. so the client knows exactly the MaxMessageSize setting which it can use.
in any case, since we are changing a default value that is impacting end-users directly, a PIP is required.
| public static int MaxMessageSize; | ||
| public static int MaxFrameSize; | ||
|
|
||
| private static String commonConfigFile = Paths.get("").toAbsolutePath().normalize().toString() + "/conf/common.conf"; |
There was a problem hiding this comment.
how can a client load this setting?
I am not sure it is a good approach to load such settings from a config file. A system property or environment variable (e.g. org.apache.pulsar.MaxMessageSize = xyz) is better.
| } | ||
|
|
||
| @Test | ||
| public void testMaxSize() { |
There was a problem hiding this comment.
We would need to have tests for when there is a mismatch between client and broker settings. Right now, a client won't attempt to send out a message bigger than 5Mb.
This should be negotiated in the connect/connected phase.
Also, what would happen if a consumer has a smaller limit and the broker is trying to push a bigger message? Current behavior would be to force close connection and immediately reconnect, in a loop. That won't be appropriate in case of a conf mismatch.
I simply think client and broker use PulsarDecoder.MaxFrameSize or PulsarDecoder.MaxMessageSize config,like: [client]
if (payloadSize > PulsarDecoder.MaxMessageSize)
if (compressedSize > PulsarDecoder.MaxMessageSize)
[broker]
new LengthFieldBasedFrameDecoder(PulsarDecoder.MaxFrameSize, 0, 4, 0, 4))I think bookie can through bookkeeper.conf set nettyMaxFrameSizeBytes can resolve,but run java example found it did not work, occured exception : [bookie-io-1-6] ERROR org.apache.bookkeeper.proto.BookieRequestHandler - Unhandled exception occurred in I/O thread or handler
io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 5242880: 32637007 - discarded
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.fail(LengthFieldBasedFrameDecoder.java:522) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.failIfNecessary(LengthFieldBasedFrameDecoder.java:500) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.exceededFrameLength(LengthFieldBasedFrameDecoder.java:387) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:430) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:343) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909) [netty-all-4.1.32.Final.jar:4.1.32.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.32.Final.jar:4.1.32.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]so nettyMaxFrameSizeBytes config to use Is the focus of the problem, tks. |
|
@ambition119 HTAL test source code: Then try to modify to less than 5M to get the information. |
pulsar config's bookkeeper.conf set nettyMaxFrameSizeBytes value is it effective? |
|
@ambition119 I modified the bookie server-side configuration file conf/bk_server.conf, and then restart the bookkeeper service |
|
It seems more appropriate to modify the environment variables,I'm interested in trying to solve this issue, tks @sijie |
Thank you for your interest in this issue, I closed this PR. |
|
@hellozepp I think @zymap is also interested in working at this issue. It might be worth checking with him :) |
|
@sijie got it,I'll get in touch with him |
Motivation
Fixes #4054
Modifications
PulsarDecoder use common.conf set MaxMessageSize value
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation