TakaHiR07 commented on code in PR #23551:
URL: https://github.com/apache/pulsar/pull/23551#discussion_r1830708626
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java:
##########
@@ -237,26 +240,25 @@ public void onResponse(OpRequestSend op) {
}
private void checkPendingRequests() {
- while (true) {
- int permits = REQUEST_CREDITS_UPDATER.get(this);
- if (permits > 0 && pendingRequests.peek() != null) {
- if (REQUEST_CREDITS_UPDATER.compareAndSet(this, permits,
permits - 1)) {
- OpRequestSend polled = pendingRequests.poll();
- if (polled != null) {
- CompletableFuture<ClientCnx> clientCnx =
getClientCnx(polled.topic);
- if (polled.cnx != clientCnx) {
- OpRequestSend invalid = polled;
- polled = OpRequestSend.create(invalid.requestId,
invalid.topic, invalid.cmd, invalid.cb,
- clientCnx);
- invalid.recycle();
- }
- endTxn(polled);
- } else {
- REQUEST_CREDITS_UPDATER.incrementAndGet(this);
+ int permits = REQUEST_CREDITS_UPDATER.get(this);
+ if (permits > 0 && pendingRequests.peek() != null) {
+ if (REQUEST_CREDITS_UPDATER.compareAndSet(this, permits, permits -
1)) {
+ OpRequestSend polled = pendingRequests.poll();
+ if (polled != null) {
+ CompletableFuture<ClientCnx> clientCnx =
getClientCnx(polled.topic);
+ if (polled.cnx != clientCnx) {
+ OpRequestSend invalid = polled;
+ polled = OpRequestSend.create(invalid.requestId,
invalid.topic, invalid.cmd, invalid.cb,
+ clientCnx);
+ invalid.recycle();
}
+ endTxn(polled);
+ } else {
+ REQUEST_CREDITS_UPDATER.incrementAndGet(this);
+ checkPendingRequests();
}
} else {
- break;
+ checkPendingRequests();
Review Comment:
The recursive calls actually may be problem. I have updated the code, the
new one is better.
--
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]