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/04/26 22:18:56 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #10285: fix issue 10284 Occasional consumer stucked when restart consumer whit key_shared subscription type

merlimat commented on a change in pull request #10285:
URL: https://github.com/apache/pulsar/pull/10285#discussion_r620688788



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java
##########
@@ -219,11 +224,16 @@ protected void sendMessagesToConsumers(ReadType readType, List<Entry> entries) {
                         sendMessageInfo.getTotalMessages(),
                         sendMessageInfo.getTotalBytes(), sendMessageInfo.getTotalChunkedMessages(),
                         getRedeliveryTracker()).addListener(future -> {
-                    if (future.isDone() && keyNumbers.decrementAndGet() == 0) {
-                        readMoreEntries();
-                    }
-                });
-
+                            if (future.isSuccess()) {
+                                Entry entry = entriesWithSameKey.get(entriesWithSameKey.size() - 1);
+                                Integer hashCode =
+                                        selector.generateKeyHash(peekStickyKey(entry.getDataBuffer()));
+                                currentSendPositionPerKeyMap.put(hashCode, entry.getPosition());

Review comment:
       Also, this would break if there is a hash collision. 

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java
##########
@@ -219,11 +224,16 @@ protected void sendMessagesToConsumers(ReadType readType, List<Entry> entries) {
                         sendMessageInfo.getTotalMessages(),
                         sendMessageInfo.getTotalBytes(), sendMessageInfo.getTotalChunkedMessages(),
                         getRedeliveryTracker()).addListener(future -> {
-                    if (future.isDone() && keyNumbers.decrementAndGet() == 0) {
-                        readMoreEntries();
-                    }
-                });
-
+                            if (future.isSuccess()) {
+                                Entry entry = entriesWithSameKey.get(entriesWithSameKey.size() - 1);
+                                Integer hashCode =
+                                        selector.generateKeyHash(peekStickyKey(entry.getDataBuffer()));
+                                currentSendPositionPerKeyMap.put(hashCode, entry.getPosition());

Review comment:
       This can potentially be storing a very large amount of `PositionImpl` instances, that will get tenured and will put pressure on the GC.




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

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