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][client] Fail messages immediately in ProducerImpl when in terminal state by merlimat · Pull Request #25317 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

When a producer reaches a terminal state (Terminated, Closed, or ProducerFenced), messages entering processOpSendMsg() would be added to pendingMessages with no connection to write them, leaving them stuck until sendTimeout (default 30s).

Add a terminal state check in processOpSendMsg() before adding to the pending queue, failing the message immediately with the appropriate exception. Also fix testTerminateWhilePublishing to close the producer after termination, since the broker's CommandCloseProducer races with CommandSendError responses, preventing the client from learning about topic termination through the normal error path.

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(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:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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:

Sorry, something went wrong.

Uh oh!

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

All reactions
@merlimat
[fix][client] Fail messages immediately in ProducerImpl when in termi…
4dd7eab
…nal state

When a producer reaches a terminal state (Terminated, Closed, or
ProducerFenced), messages entering processOpSendMsg() would be added
to pendingMessages with no connection to write them, leaving them
stuck until sendTimeout (default 30s).

Add a terminal state check in processOpSendMsg() before adding to
the pending queue, failing the message immediately with the
appropriate exception. Also fix testTerminateWhilePublishing to
close the producer after termination, since the broker's
CommandCloseProducer races with CommandSendError responses,
preventing the client from learning about topic termination through
the normal error path.
@merlimat merlimat added this to the 4.2.0 milestone Mar 12, 2026
@merlimat
merlimat requested review from lhotari, poorbarcode and shibd March 12, 2026 21:29
@merlimat merlimat added area/client ready-to-test release/4.1.4 release/4.0.10 release/3.0.17 labels Mar 12, 2026
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Mar 12, 2026
@merlimat
removed unused import
146ef82
@codecov-commenter

codecov-commenter commented Mar 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 11.76471% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.66%. Comparing base (b171b05) to head (146ef82).
⚠️ Report is 128 commits behind head on master.

Files with missing lines Patch % Lines
...va/org/apache/pulsar/client/impl/ProducerImpl.java 11.76% 14 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             master   #25317    +/-   ##
==========================================
  Coverage     72.66%   72.66%            
+ Complexity    34651    34244   -407     
==========================================
  Files          1967     1967            
  Lines        156326   156342    +16     
  Branches      17812    17813     +1     
==========================================
+ Hits         113591   113612    +21     
+ Misses        33671    33638    -33     
- Partials       9064     9092    +28     
Flag Coverage Δ
inttests 25.76% <5.88%> (+0.05%) ⬆️
systests 22.29% <11.76%> (-0.19%) ⬇️
unittests 73.63% <11.76%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
...va/org/apache/pulsar/client/impl/ProducerImpl.java 83.30% <11.76%> (-0.90%) ⬇️

... and 97 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 approved these changes Mar 16, 2026
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 reviewed Mar 16, 2026
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

@lhotari
lhotari merged commit 1b5c818 into apache:master Mar 16, 2026
102 of 104 checks passed

Uh oh!

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

@merlimat
merlimat deleted the fix-termination-test branch March 16, 2026 19:30
coderzc pushed a commit to coderzc/pulsar that referenced this pull request Mar 19, 2026
@merlimat @coderzc
[fix][client] Fail messages immediately in ProducerImpl when in termi…
11f30ad
…nal state (apache#25317)
@coderzc coderzc added the cherry-picked/branch-4.0 label Mar 19, 2026
Technoboy- pushed a commit that referenced this pull request Mar 19, 2026
@merlimat @Technoboy-
[fix][client] Fail messages immediately in ProducerImpl when in termi…
32732d6
…nal state (#25317)
@Technoboy- Technoboy- assigned merlimat Mar 19, 2026
@Technoboy- Technoboy- added the cherry-picked/branch-4.1 label Mar 19, 2026
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 1, 2026
@merlimat @priyanshu-ctds
[fix][client] Fail messages immediately in ProducerImpl when in termi…
1ea1e00
…nal state (apache#25317)

(cherry picked from commit 11f30ad)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 1, 2026
@merlimat @priyanshu-ctds
[fix][client] Fail messages immediately in ProducerImpl when in termi…
4ed06ea
…nal state (apache#25317)

(cherry picked from commit 11f30ad)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 2, 2026
@merlimat @priyanshu-ctds
[fix][client] Fail messages immediately in ProducerImpl when in termi…
5a70ee5
…nal state (apache#25317)

(cherry picked from commit 11f30ad)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 3, 2026
@merlimat @priyanshu-ctds
[fix][client] Fail messages immediately in ProducerImpl when in termi…
550ee03
…nal state (apache#25317)

(cherry picked from commit 11f30ad)
lhotari pushed a commit that referenced this pull request Apr 21, 2026
@merlimat @lhotari
[fix][client] Fail messages immediately in ProducerImpl when in termi…
0aa4dca
…nal state (#25317)

(cherry picked from commit 1b5c818)
@lhotari lhotari added the cherry-picked/branch-3.0 label Apr 21, 2026
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 22, 2026
@merlimat @priyanshu-ctds
[fix][client] Fail messages immediately in ProducerImpl when in termi…
cd1b911
…nal state (apache#25317)

(cherry picked from commit 1b5c818)
(cherry picked from commit 0aa4dca)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request May 12, 2026
@merlimat @nodece
[fix][client] Fail messages immediately in ProducerImpl when in termi…
5f681c4
…nal state (apache#25317)

(cherry picked from commit 1b5c818)
@lhotari lhotari mentioned this pull request Sep 5, 2026
[Bug] ProducerImpl releases a message's memory reservation twice in the terminal-state branch, permanently degrading the client memory limit #26469
Open
2 of 3 tasks
@SongOf SongOf mentioned this pull request Sep 6, 2026
[fix][client] Release the reserved memory only once when failing a send in a terminal state #26476
Merged
10 tasks
@merlimat merlimat mentioned this pull request Nov 9, 2026
[fix][client] Fail a batched send whose producer ends before the message is batched #27529
Merged
10 tasks
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
@poorbarcode poorbarcode Awaiting requested review from poorbarcode
@shibd shibd Awaiting requested review from shibd

Uh oh!

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

Assignees

@merlimat merlimat

Labels

area/client cherry-picked/branch-3.0 cherry-picked/branch-4.0 cherry-picked/branch-4.1 doc-not-needed Your PR changes do not impact docs ready-to-test release/3.0.17 release/4.0.10 release/4.1.4

Projects

None yet

Milestone

4.2.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

5 participants

@merlimat @codecov-commenter @lhotari @Technoboy- @coderzc
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.