congbobo184 commented on code in PR #18478:
URL: https://github.com/apache/pulsar/pull/18478#discussion_r1027221923


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java:
##########
@@ -836,12 +847,19 @@ protected boolean canEnqueueMessage(Message<T> message) {
 
     protected boolean enqueueMessageAndCheckBatchReceive(Message<T> message) {
         int messageSize = message.size();
-        if (canEnqueueMessage(message) && incomingMessages.offer(message)) {
-            // After we have enqueued the messages on `incomingMessages` 
queue, we cannot touch the message instance
-            // anymore, since for pooled messages, this instance was possibly 
already been released and recycled.
-            INCOMING_MESSAGES_SIZE_UPDATER.addAndGet(this, messageSize);
-            getMemoryLimitController().ifPresent(limiter -> 
limiter.forceReserveMemory(messageSize));
-            updateAutoScaleReceiverQueueHint();
+        // synchronize redeliverUnacknowledgedMessages().
+        incomingQueueLock.lock();
+        try {
+            if (canEnqueueMessage(message) && incomingMessages.offer(message)) 
{

Review Comment:
   add lock but don't check the epoch, it also can't filter the message that 
the epoch is smaller than the current epoch, right? @Technoboy- @codelipenghui 



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

Reply via email to