lhotari commented on code in PR #4713:
URL: https://github.com/apache/bookkeeper/pull/4713#discussion_r2897421512
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingWriteLacOp.java:
##########
@@ -114,5 +117,15 @@ public void writeLacComplete(int rc, long ledgerId,
BookieId addr, Object ctx) {
completed = true;
cb.addLacComplete(lastSeenError, lh, ctx);
}
+
+ maybeRecycle();
}
+
+ private void maybeRecycle() {
+ if (receivedResponseSet.isEmpty() && toSend != null) {
+ ReferenceCountUtil.release(toSend);
Review Comment:
I'm just wondering what `initiate` doesn't handle the reference count of the
`toSend` buffer properly?
I'd do something like this instead:
```
private void sendWriteLacRequest(ByteBufList toSend, int bookieIndex) {
clientCtx.getBookieClient().writeLac(currentEnsemble.get(bookieIndex),
lh.ledgerId, lh.ledgerKey, lac,
toSend, this, bookieIndex);
}
void initiate(ByteBufList toSend) {
try {
for (int i = 0; i <
lh.distributionSchedule.getWriteQuorumSize(); i++) {
sendWriteLacRequest(toSend,
lh.distributionSchedule.getWriteSetBookieIndex(lac, i));
}
} finally {
toSend.release();
}
}
```
and remove the `toSend` field completely. The bookie client's `writeLac`
will handle the reference counting properly from there on. I happened to work
on something related in #4293.
--
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]