tjiuming opened a new pull request, #19157: URL: https://github.com/apache/pulsar/pull/19157
### 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`](https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/SingleSnapshotAbortedTxnProcessorImpl.java#L57), and the write will held by [`SystemTopicClientBase#writers`](https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/systopic/SystemTopicClientBase.java#L76). 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 https://github.com/apache/pulsar/pull/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 <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
