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

[fix] [client] Fix memory leak when publishing encountered a corner case error #23738

Merged
merged 20 commits into from
Dec 20, 2024

Conversation

poorbarcode
Copy link
Contributor

@poorbarcode poorbarcode commented Dec 16, 2024

Motivation

Issue 1: memory leak if get errors when publishing
Conditions:

  • Send queue is full
  • Or reaches the limitation named max message size
  • Or publishes after closing the producer
  • Or encounters an error when calling ProducerInterceptor. eligible
  • see testSendQueueIsFull, testSendMessageSizeExceeded, testSendAfterClosedProducer, and testInterceptorError

Modifications

  • Fix issues

Documentation

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

Matching PR in forked repository

PR in forked repository: x

@poorbarcode poorbarcode added type/bug The PR fixed a bug or issue reported a bug release/3.0.9 release/3.3.4 release/4.0.2 labels Dec 16, 2024
@poorbarcode poorbarcode added this to the 4.1.0 milestone Dec 16, 2024
@poorbarcode poorbarcode self-assigned this Dec 16, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 16, 2024
@poorbarcode
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@poorbarcode poorbarcode changed the title [fix] [client] Fix memory leak and publish stuck when publishing [fix] [client] Fix memory leak when publishing encountered a corner case error Dec 17, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.31%. Comparing base (bbc6224) to head (9f99fd2).
Report is 801 commits behind head on master.

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

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23738      +/-   ##
============================================
+ Coverage     73.57%   74.31%   +0.73%     
+ Complexity    32624     2374   -30250     
============================================
  Files          1877     1838      -39     
  Lines        139502   143053    +3551     
  Branches      15299    16232     +933     
============================================
+ Hits         102638   106304    +3666     
+ Misses        28908    28376     -532     
- Partials       7956     8373     +417     
Flag Coverage Δ
inttests 26.75% <23.52%> (+2.17%) ⬆️
systests 23.71% <23.52%> (-0.62%) ⬇️
unittests 73.66% <94.11%> (+0.82%) ⬆️

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

Files with missing lines Coverage Δ
.../pulsar/client/impl/BatchMessageContainerImpl.java 85.79% <100.00%> (+4.89%) ⬆️
...pache/pulsar/client/impl/ProducerInterceptors.java 72.50% <100.00%> (ø)
...va/org/apache/pulsar/client/impl/ProducerImpl.java 84.00% <90.90%> (+0.40%) ⬆️

... and 1007 files with indirect coverage changes

@poorbarcode
Copy link
Contributor Author

poorbarcode commented Dec 19, 2024

@codelipenghui

The fix looks good me, but when I try to run the newly added test on the master branch (without this fix). A lot of test cases can still get passed. Could you please help if this is expected?

  • testSendMessageSizeExceeded: it should fail when the @param is larger than 1, I improved the test, and it is fine now.
  • testBatchedSendMessageSizeExceeded: it is expected that the tests can pass because the batch message will only check the max message size that excludes message metadata
  • testInterceptorError: only @param eligible has an issue, so it is expected.

@poorbarcode poorbarcode requested review from codelipenghui and BewareMyPower and removed request for BewareMyPower December 19, 2024 07:24
@poorbarcode poorbarcode merged commit ab1b5c0 into apache:master Dec 20, 2024
52 checks passed
@lhotari
Copy link
Member

lhotari commented Dec 20, 2024

@poorbarcode @BewareMyPower Please review #23761, that addresses a long time issue where the completable futures of pending messages weren't completed when close was called. It's also a case which could result into a resource leak situation.

lhotari pushed a commit that referenced this pull request Dec 20, 2024
…ase error (#23738)

Co-authored-by: Yunze Xu <xyzinfernity@163.com>
(cherry picked from commit ab1b5c0)
lhotari pushed a commit that referenced this pull request Dec 20, 2024
…ase error (#23738)

Co-authored-by: Yunze Xu <xyzinfernity@163.com>
(cherry picked from commit ab1b5c0)
lhotari pushed a commit that referenced this pull request Dec 20, 2024
…ase error (#23738)

Co-authored-by: Yunze Xu <xyzinfernity@163.com>
(cherry picked from commit ab1b5c0)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Dec 26, 2024
…ase error (apache#23738)

Co-authored-by: Yunze Xu <xyzinfernity@163.com>
(cherry picked from commit ab1b5c0)
(cherry picked from commit 7915b66)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Dec 26, 2024
…ase error (apache#23738)

Co-authored-by: Yunze Xu <xyzinfernity@163.com>
(cherry picked from commit ab1b5c0)
(cherry picked from commit 7915b66)
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.

6 participants