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/08/10 04:51:21 UTC

[GitHub] [pulsar] coderzc opened a new pull request, #17032: [fix][broker] Filter out already delete entry again before send message to consumer

coderzc opened a new pull request, #17032:
URL: https://github.com/apache/pulsar/pull/17032

   Fixes #16949
   
   ### Motivation
   
   Now, sending messages to the consumer using io-thread. When the task is scheduled, the message ack may be already changed leading to delivering the message of already been acknowledged.
   
   ### Modifications
   
   Filter out already delete entries again before sending message to the consumer.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API: (yes / no)
     - The schema: (yes / no / don't know)
     - The default values of configurations: (yes / no)
     - The wire protocol: (yes / no)
     - The rest endpoints: (yes / no)
     - The admin cli options: (yes / no)
     - Anything that affects deployment: (yes / no / don't know)
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x] `doc-not-needed` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already 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] coderzc commented on pull request #17032: [fix][broker] Filter out already delete entry again before send message to consumer

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1210479003

   /pulsarbot run-failure-checks


-- 
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] congbobo184 commented on pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged

Posted by GitBox <gi...@apache.org>.
congbobo184 commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1318546456

   @coderzc  hi, I move this PR to release/2.9.5, if you have any questions, please ping me. thanks.


-- 
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] coderzc commented on pull request #17032: [fix][broker] Filter out already delete entry again before send message to consumer

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1212691083

   /pulsarbot run-failure-checks


-- 
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] coderzc commented on pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1213013839

   @codelipenghui PTAL


-- 
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 commented on pull request #17032: [fix][broker] Filter out already delete entry again before send message to consumer

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1210932310

   @coderzc Please rebase to the master branch.


-- 
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] github-actions[bot] commented on pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#issuecomment-1258877235

   The pr had no activity for 30 days, mark with Stale label.


-- 
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 commented on a diff in pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #17032:
URL: https://github.com/apache/pulsar/pull/17032#discussion_r945023402


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java:
##########
@@ -220,20 +223,36 @@ public void sendReachedEndOfTopic(long consumerId) {
     }
 
     @Override
-    public ChannelPromise sendMessagesToConsumer(long consumerId, String topicName, Subscription subscription,
+    public ChannelPromise sendMessagesToConsumer(Consumer consumer, String topicName, Subscription subscription,
                                                  int partitionIdx, List<? extends Entry> entries,
                                                  EntryBatchSizes batchSizes, EntryBatchIndexesAcks batchIndexesAcks,
                                                  RedeliveryTracker redeliveryTracker, long epoch) {
         final ChannelHandlerContext ctx = cnx.ctx();
         final ChannelPromise writePromise = ctx.newPromise();
+        final long consumerId = consumer.consumerId();
         ctx.channel().eventLoop().execute(() -> {
+            ManagedCursorImpl cursor = null;
+            if (subscription instanceof PersistentSubscription persistentSubscription
+                    && !(subscription instanceof CompactorSubscription)
+                    && !consumer.readCompacted()) {
+                cursor = (ManagedCursorImpl) persistentSubscription.getCursor();
+            }
+
             for (int i = 0; i < entries.size(); i++) {
                 Entry entry = entries.get(i);
                 if (entry == null) {
                     // Entry was filtered out
                     continue;
                 }
 
+                // Filter out already delete entry, because message ack may be already has changed
+                if (cursor != null && cursor.isDurable()) {
+                  if (cursor.isMessageDeleted(entry.getPosition())) {
+                      entry.release();
+                      continue;
+                  }

Review Comment:
   The available permits had decreased before but here skipped the data, it might introduce a case that the consumer can't receive any messages because the available permits of this consumer at the server-side is 0.



-- 
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] coderzc closed pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged

Posted by GitBox <gi...@apache.org>.
coderzc closed pull request #17032: [fix][broker] Fix delivery the message that has been acknowledged
URL: https://github.com/apache/pulsar/pull/17032


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