Skip to content

[fix][broker] Close transactionBuffer after MessageDeduplication#checkStatus failed#19157

Merged
codelipenghui merged 4 commits intoapache:masterfrom
tjiuming:fix/deduplication_check_failed
Jan 17, 2023
Merged

[fix][broker] Close transactionBuffer after MessageDeduplication#checkStatus failed#19157
codelipenghui merged 4 commits intoapache:masterfrom
tjiuming:fix/deduplication_check_failed

Conversation

@tjiuming
Copy link
Contributor

@tjiuming tjiuming commented Jan 9, 2023

Motivation

Currently, we didn't close the TransactionBuffer after MessageDeduplication#checkStatus failed. see: https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java#L1600
it will lead to memory leak.
In TopicTransactionBuffer, it will create a snapshotWrite in SingleSnapshotAbortedTxnProcessorImpl, and the write will held by SystemTopicClientBase#writers.

If we don't close the TransactionBuffer after MessageDeduplication#checkStatus failed, the number of TransactionBufferSnapshotWriter held by SystemTopicClientBase#writers will keep increasing, and may lead to OOM in the finally.

In #15015 , it reuses the TransactionBufferSnapshotWriter, which means that the topics of a same namespace will use one single TransactionBufferSnapshotWriter instance, it greatly reduces the amount of memory leaks, but if we don't close the TransactionBuffer, there are still memory leak risks.

Documentation

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

Matching PR in forked repository

PR in forked repository: tjiuming#17

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2023

Codecov Report

Merging #19157 (821604f) into master (253e3e4) will increase coverage by 1.05%.
The diff coverage is 61.29%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19157      +/-   ##
============================================
+ Coverage     46.24%   47.30%   +1.05%     
- Complexity    10145    10718     +573     
============================================
  Files           687      713      +26     
  Lines         67483    69731    +2248     
  Branches       7252     7497     +245     
============================================
+ Hits          31208    32985    +1777     
- Misses        32693    33030     +337     
- Partials       3582     3716     +134     
Flag Coverage Δ
unittests 47.30% <61.29%> (+1.05%) ⬆️

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

Impacted Files Coverage Δ
...che/bookkeeper/mledger/offload/OffloaderUtils.java 1.47% <0.00%> (ø)
.../org/apache/pulsar/broker/admin/v2/Namespaces.java 56.50% <0.00%> (-1.79%) ⬇️
...ulsar/broker/intercept/BrokerInterceptorUtils.java 10.71% <0.00%> (ø)
.../broker/loadbalance/impl/PulsarLoadReportImpl.java 0.00% <0.00%> (ø)
...e/pulsar/broker/protocol/ProtocolHandlerUtils.java 10.71% <0.00%> (ø)
...java/org/apache/pulsar/broker/rest/TopicsBase.java 0.00% <0.00%> (ø)
...va/org/apache/pulsar/broker/service/ServerCnx.java 49.32% <ø> (+5.14%) ⬆️
...sar/broker/service/plugin/EntryFilterProvider.java 0.00% <0.00%> (ø)
...org/apache/pulsar/broker/web/ExceptionHandler.java 0.00% <0.00%> (ø)
...rg/apache/pulsar/broker/web/PulsarWebResource.java 55.69% <ø> (-1.79%) ⬇️
... and 144 more

Copy link
Contributor

@Technoboy- Technoboy- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@congbobo184 congbobo184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to add a test for it

@codelipenghui codelipenghui merged commit d25cf8e into apache:master Jan 17, 2023
@codelipenghui
Copy link
Contributor

@tjiuming Could you please help create a PR to cherry-pick the fix to branch-2.11, branch-2.10 and branch-2.9?

@tjiuming
Copy link
Contributor Author

#19287
#19288
#19289

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.

9 participants