You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/09/19 14:27:59 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4224: ARTEMIS-4003 Fixing credit starve on Large Message over the bridge or clustering

clebertsuconic commented on code in PR #4224:
URL: https://github.com/apache/activemq-artemis/pull/4224#discussion_r974320869


##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java:
##########
@@ -144,24 +144,46 @@ public synchronized int decrementRefCount() {
 
    protected void checkCredits(final int credits) {
       int needed = Math.max(credits, windowSize);
+      if (logger.isTraceEnabled()) {
+         logger.tracef("CheckCredits %s on address %s, needed=%s, credits=%s, window=%s", credits, address, needed, credits, windowSize);
+      }
 
       int toRequest = -1;
 
       synchronized (this) {
          if (getBalance() + arriving < needed) {
             toRequest = needed - arriving;
 
-            pendingCredits += toRequest;
-            arriving += toRequest;
+            if (logger.isTraceEnabled()) {
+               logger.tracef("CheckCredits on Address %s, requesting=%s, arriving=%s, balance=%s", address, toRequest, arriving, getBalance());
+            }
+         } else {
+            if (logger.isTraceEnabled()) {
+               logger.tracef("CheckCredits did not need it, balance=%s, arriving=%s,  needed=%s, getbalance + arriving < needed=%s", getBalance(), arriving, needed, (boolean)(getBalance() + arriving < needed));
+            }
          }
       }
 
-      if (toRequest != -1) {
+      if (toRequest > 0) {
+         if (logger.isDebugEnabled()) {
+            logger.debugf("Requesting %s credits on address %s, needed = %s, arriving = %s", toRequest, address, needed, arriving);
+         }
          requestCredits(toRequest);
+      } else {
+         logger.debugf("not asking for %s credits on %s", toRequest, address);
       }
    }
 
-   private void requestCredits(final int credits) {
+   @Override
+   public String toString() {

Review Comment:
   hmmm... I did not mean to merge this line.. I will remove it.



-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org