You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/27 15:18:25 UTC

[GitHub] [pulsar] codelipenghui opened a new pull request #12212: Fix returned wrong hash ranges for the consumer with same consumer name

codelipenghui opened a new pull request #12212:
URL: https://github.com/apache/pulsar/pull/12212


   Currently, we are using the consumer name to generate the hash ranges to the admin client.
   If there are consumers with the same name, we will get same hash ranges for different consumers,
   this will confuse when troubleshooting issue. The following is an example:
   
   ```
   "consumers" : [ {
           "msgRateOut" : 0.0,
           "msgThroughputOut" : 0.0,
           "bytesOutCounter" : 46320,
           "msgOutCounter" : 1020,
           "msgRateRedeliver" : 0.0,
           "chunkedMessageRate" : 0.0,
           "consumerName" : "5253f",
           "availablePermits" : -20,
           "unackedMessages" : 1000,
           "avgMessagesPerEntry" : 56,
           "blockedConsumerOnUnackedMsgs" : false,
           "readPositionWhenJoining" : "10:11494",
           "lastAckedTimestamp" : 1632731049993,
           "lastConsumedTimestamp" : 1632731030268,
           "keyHashRanges" : [ "[0, 16384]" ],
           "metadata" : { },
           "address" : "/127.0.0.1:54702",
           "connectedSince" : "2021-09-27T16:23:49.891+08:00",
           "clientVersion" : "2.8.1"
         }, {
           "msgRateOut" : 0.0,
           "msgThroughputOut" : 0.0,
           "bytesOutCounter" : 0,
           "msgOutCounter" : 0,
           "msgRateRedeliver" : 0.0,
           "chunkedMessageRate" : 0.0,
           "consumerName" : "my-name",
           "availablePermits" : 10,
           "unackedMessages" : 0,
           "avgMessagesPerEntry" : 1000,
           "blockedConsumerOnUnackedMsgs" : false,
           "readPositionWhenJoining" : "10:19505",
           "lastAckedTimestamp" : 0,
           "lastConsumedTimestamp" : 0,
           "keyHashRanges" : [ "[16385, 40960]", "[40961, 65536]" ],
           "metadata" : { },
           "address" : "/127.0.0.1:54708",
           "connectedSince" : "2021-09-27T16:23:59.031+08:00",
           "clientVersion" : "2.8.1"
         }, {
           "msgRateOut" : 0.0,
           "msgThroughputOut" : 0.0,
           "bytesOutCounter" : 0,
           "msgOutCounter" : 0,
           "msgRateRedeliver" : 0.0,
           "chunkedMessageRate" : 0.0,
           "consumerName" : "my-name",
           "availablePermits" : 10,
           "unackedMessages" : 0,
           "avgMessagesPerEntry" : 1000,
           "blockedConsumerOnUnackedMsgs" : false,
           "readPositionWhenJoining" : "10:19514",
           "lastAckedTimestamp" : 0,
           "lastConsumedTimestamp" : 0,
           "keyHashRanges" : [ "[16385, 40960]", "[40961, 65536]" ],
           "metadata" : { },
           "address" : "/127.0.0.1:54717",
           "connectedSince" : "2021-09-27T16:24:03.927+08:00",
           "clientVersion" : "2.8.1"
         } ],
   ```
   
   The fix is to use the equals method of the consumer to generate the key hash ranges.
   New tests added.


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] codelipenghui merged pull request #12212: Fix returned wrong hash ranges for the consumer with same consumer name

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #12212:
URL: https://github.com/apache/pulsar/pull/12212


   


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] codelipenghui merged pull request #12212: Fix returned wrong hash ranges for the consumer with same consumer name

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #12212:
URL: https://github.com/apache/pulsar/pull/12212


   


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] 315157973 commented on a change in pull request #12212: Fix returned wrong hash ranges for the consumer with same consumer name

Posted by GitBox <gi...@apache.org>.
315157973 commented on a change in pull request #12212:
URL: https://github.com/apache/pulsar/pull/12212#discussion_r717312770



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java
##########
@@ -1034,8 +1036,10 @@ public SubscriptionStatsImpl getStats(Boolean getPreciseBacklog, boolean subscri
                 subStats.lastConsumedTimestamp =
                         Math.max(subStats.lastConsumedTimestamp, consumerStats.lastConsumedTimestamp);
                 subStats.lastAckedTimestamp = Math.max(subStats.lastAckedTimestamp, consumerStats.lastAckedTimestamp);
-                if (consumerKeyHashRanges != null && consumerKeyHashRanges.containsKey(consumer.consumerName())) {
-                    consumerStats.keyHashRanges = consumerKeyHashRanges.get(consumer.consumerName());
+                if (consumerKeyHashRanges != null && consumerKeyHashRanges.containsKey(consumer)) {
+                    consumerStats.keyHashRanges = consumerKeyHashRanges.get(consumer).stream()
+                            .map(range -> String.format("[%s, %s]", range.getStart(), range.getEnd()))

Review comment:
       We can use range.toString()




-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] 315157973 commented on a change in pull request #12212: Fix returned wrong hash ranges for the consumer with same consumer name

Posted by GitBox <gi...@apache.org>.
315157973 commented on a change in pull request #12212:
URL: https://github.com/apache/pulsar/pull/12212#discussion_r717312770



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java
##########
@@ -1034,8 +1036,10 @@ public SubscriptionStatsImpl getStats(Boolean getPreciseBacklog, boolean subscri
                 subStats.lastConsumedTimestamp =
                         Math.max(subStats.lastConsumedTimestamp, consumerStats.lastConsumedTimestamp);
                 subStats.lastAckedTimestamp = Math.max(subStats.lastAckedTimestamp, consumerStats.lastAckedTimestamp);
-                if (consumerKeyHashRanges != null && consumerKeyHashRanges.containsKey(consumer.consumerName())) {
-                    consumerStats.keyHashRanges = consumerKeyHashRanges.get(consumer.consumerName());
+                if (consumerKeyHashRanges != null && consumerKeyHashRanges.containsKey(consumer)) {
+                    consumerStats.keyHashRanges = consumerKeyHashRanges.get(consumer).stream()
+                            .map(range -> String.format("[%s, %s]", range.getStart(), range.getEnd()))

Review comment:
       We can use range.toString()




-- 
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: commits-unsubscribe@pulsar.apache.org

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