Skip to content

[fix][client] Fail messages immediately in ProducerImpl when in terminal state#25317

Open
merlimat wants to merge 2 commits intoapache:masterfrom
merlimat:fix-termination-test
Open

[fix][client] Fail messages immediately in ProducerImpl when in terminal state#25317
merlimat wants to merge 2 commits intoapache:masterfrom
merlimat:fix-termination-test

Conversation

@merlimat
Copy link
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:

…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.
@codecov-commenter
Copy link

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 2 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.

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.

2 participants