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 2022/06/13 02:51:48 UTC

[GitHub] [pulsar] Jason918 commented on a diff in pull request #15963: [fix][broker] KeyShared stickyHashRange subscription: Fix not be able to receive a message when send a can‘t match consumer message

Jason918 commented on code in PR #15963:
URL: https://github.com/apache/pulsar/pull/15963#discussion_r895289610


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java:
##########
@@ -215,13 +219,19 @@ protected void sendMessagesToConsumers(ReadType readType, List<Entry> entries) {
         final Map<Consumer, Set<Integer>> consumerStickyKeyHashesMap = new HashMap<>();
 
         for (Entry entry : entries) {
-            int stickyKeyHash = getStickyKeyHash(entry);
+            final int stickyKeyHash = getStickyKeyHash(entry);
+            final long ledgerId = entry.getLedgerId();
+            final long entryId = entry.getEntryId();
             Consumer c = selector.select(stickyKeyHash);
             if (c != null) {
                 groupedEntries.computeIfAbsent(c, k -> new ArrayList<>()).add(entry);
                 consumerStickyKeyHashesMap.computeIfAbsent(c, k -> new HashSet<>()).add(stickyKeyHash);
+                unMatchConsumerBackoff.reset();
             } else {
-                addMessageToReplay(entry.getLedgerId(), entry.getEntryId(), stickyKeyHash);
+                topic.getBrokerService().executor().schedule(() -> {
+                    addMessageToReplay(ledgerId, entryId, stickyKeyHash);
+                }, unMatchConsumerBackoff.next(), TimeUnit.MILLISECONDS);

Review Comment:
   `unMatchConsumerBackoff.next()` seems odd here.
   Consider the case when all entry in `entries` have the same `stickyKeyHash`, the delay time increases in the same batch entries.



-- 
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