lhotari commented on code in PR #23983:
URL: https://github.com/apache/pulsar/pull/23983#discussion_r1955031288
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -671,8 +671,15 @@ public void updateSubscribeRateLimiter() {
}
private void asyncAddEntry(ByteBuf headersAndPayload, PublishContext
publishContext) {
- ledger.asyncAddEntry(headersAndPayload,
- (int) publishContext.getNumberOfMessages(), this, publishContext);
+ // Retain the buffer in advance to avoid the buffer might have been
released when it's passed to `asyncAddEntry`
+ final var buffer = headersAndPayload.retain();
Review Comment:
Just wondering if this is going to add an extra reference compared to the
previous code.
I have a solution in #23956 to reliably detect Netty ByteBuf leaks so those
changes are one way to validate whether there's a new leak.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -671,8 +671,15 @@ public void updateSubscribeRateLimiter() {
}
private void asyncAddEntry(ByteBuf headersAndPayload, PublishContext
publishContext) {
- ledger.asyncAddEntry(headersAndPayload,
- (int) publishContext.getNumberOfMessages(), this, publishContext);
+ // Retain the buffer in advance to avoid the buffer might have been
released when it's passed to `asyncAddEntry`
+ final var buffer = headersAndPayload.retain();
+ try {
+ ledger.getExecutor().execute(() -> ledger.asyncAddEntry(buffer,
(int) publishContext.getNumberOfMessages(),
+ this, publishContext));
Review Comment:
this should be an internal concern of the ManagedLedger implementation's
`asyncAddEntry` method. One reason for this is that there's multiple
`asyncAddEntry` signatures and we'd like to add them all in order.
--
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]