Skip to content

Conversation

@lhotari
Copy link
Member

@lhotari lhotari commented Aug 14, 2025

Motivation

Using the Pulsar Proxy could result in a TooLongFrameException.

When the Pulsar Proxy switches to direct proxy mode, it removes the frame decoder:

private void startDirectProxying(CommandConnected connected) {
if (service.getProxyLogLevel() == 0) {
if (log.isDebugEnabled()) {
log.debug("[{}] [{}] Removing decoder from pipeline", inboundChannel, outboundChannel);
}
// direct tcp proxy
inboundChannel.pipeline().remove("frameDecoder");
outboundChannel.pipeline().remove("frameDecoder");

However, this fails since the client changes the "frameDecoder" handler's name to "newFrameDecoder"

if (connected.hasMaxMessageSize()) {
if (log.isDebugEnabled()) {
log.debug("{} Connection has max message size setting, replace old frameDecoder with "
+ "server frame size {}", ctx.channel(), connected.getMaxMessageSize());
}
maxMessageSize = connected.getMaxMessageSize();
ctx.pipeline().replace("frameDecoder", "newFrameDecoder", new LengthFieldBasedFrameDecoder(
connected.getMaxMessageSize() + Commands.MESSAGE_SIZE_FRAME_PADDING, 0, 4, 0, 4));
}

A possible workaround is to use proxyZeroCopyModeEnabled=true since in the zero copy mode, the channel handlers are ignored. The Zero copy mode cannot be enabled when TLS is enabled between the Pulsar Proxy and Pulsar Brokers.

Modifications

  • fix the issue in removing the frame decoder when switching to direct proxy mode
  • refactor frame decoder logic to reduce code duplication and future errors

Documentation

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

@lhotari lhotari added this to the 4.1.0 milestone Aug 14, 2025
@lhotari lhotari self-assigned this Aug 14, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 14, 2025
@lhotari lhotari added release/4.0.7 release/3.0.14 release/3.3.9 type/bug The PR fixed a bug or issue reported a bug labels Aug 14, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.25%. Comparing base (baa288a) to head (b2934e6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24626      +/-   ##
============================================
- Coverage     74.28%   74.25%   -0.03%     
+ Complexity    33153    32783     -370     
============================================
  Files          1881     1882       +1     
  Lines        146850   146853       +3     
  Branches      16866    16866              
============================================
- Hits         109083   109051      -32     
- Misses        29089    29128      +39     
+ Partials       8678     8674       -4     
Flag Coverage Δ
inttests 26.70% <77.77%> (+0.22%) ⬆️
systests 23.26% <77.77%> (-0.06%) ⬇️
unittests 73.75% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...ulsar/broker/service/PulsarChannelInitializer.java 94.54% <100.00%> (-0.10%) ⬇️
.../java/org/apache/pulsar/client/impl/ClientCnx.java 69.21% <100.00%> (-0.04%) ⬇️
...e/pulsar/client/impl/PulsarChannelInitializer.java 86.23% <100.00%> (-1.84%) ⬇️
...pache/pulsar/common/protocol/FrameDecoderUtil.java 100.00% <100.00%> (ø)
...apache/pulsar/proxy/server/DirectProxyHandler.java 72.76% <100.00%> (-0.23%) ⬇️
...pulsar/proxy/server/ServiceChannelInitializer.java 86.79% <100.00%> (ø)

... and 82 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.

@lhotari lhotari merged commit cde4948 into apache:master Aug 14, 2025
146 of 150 checks passed
lhotari added a commit that referenced this pull request Aug 14, 2025
lhotari added a commit that referenced this pull request Aug 14, 2025
lhotari added a commit that referenced this pull request Aug 14, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
(cherry picked from commit cde4948)
(cherry picked from commit ba3b6cb)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
(cherry picked from commit cde4948)
(cherry picked from commit ba3b6cb)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 21, 2025
(cherry picked from commit cde4948)
(cherry picked from commit 1e678f4)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 26, 2025
(cherry picked from commit cde4948)
(cherry picked from commit 1e678f4)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 26, 2025
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Sep 10, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants