You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "1Jack2 (via GitHub)" <gi...@apache.org> on 2023/11/20 00:36:02 UTC

[PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

1Jack2 opened a new pull request, #21592:
URL: https://github.com/apache/pulsar/pull/21592

   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*. 
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   -->
   
   <!-- Either this PR fixes an issue, -->
   Fixes #21568
   
   <!-- or this PR is one task of an issue -->
   
   
   <!-- If the PR belongs to a PIP, please add the PIP link here -->
   
   
   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/wiki/proposals/PIP.md -->
   
   ### Motivation
   
   <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
   Fix incorrect unack count when using shared subscription on non-persistent topic
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   In the case of a non-persistent topic, the consumer does not send an ack to the broker (see `org.apache.pulsar.client.impl.NonPersistentAcknowledgmentGroupingTracker# addAcknowledgment`)
     
   To work around this, we can update `unackedMessages` when the broker sends a message to the consumer successfully.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   https://github.com/1Jack2/pulsar/pull/5
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1406099564


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (isDurable && Subscription.isIndividualAckMode(subType)) {

Review Comment:
   If we create a no-durable consumer under a persistent topic, the field `isDurable` is also `false`, right? How could we cover this case?



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1399948546


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (Subscription.isIndividualAckMode(subType) && subscription instanceof PersistentSubscription) {

Review Comment:
   `subscription instanceof PersistentSubscription` or `isDurable` more better ?



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1410046888


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (subscription.getTopic() instanceof PersistentTopic && Subscription.isIndividualAckMode(subType)) {

Review Comment:
   yes, could you add a field 'isPersistentTopic' in this class and get this value in the constructor?



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "1Jack2 (via GitHub)" <gi...@apache.org>.
1Jack2 commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1410099475


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -239,6 +243,7 @@ public Consumer(Subscription subscription, SubType subType, String topicName, lo
         this.pendingAcks = null;
         this.stats = null;
         this.isDurable = false;
+        this.isPersistentTopic = true;

Review Comment:
   > The default value should be `false`.
   
   fixed



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode merged PR #21592:
URL: https://github.com/apache/pulsar/pull/21592


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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#issuecomment-1833111973

   @1Jack2 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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#issuecomment-1833332350

   ## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/21592?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#21592](https://app.codecov.io/gh/apache/pulsar/pull/21592?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (2fd027d) into [master](https://app.codecov.io/gh/apache/pulsar/commit/403faa4c77862062e638e95fc36c4ee53c5b8f41?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (403faa4) will **decrease** coverage by `0.05%`.
   > Report is 22 commits behind head on master.
   > The diff coverage is `100.00%`.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/pulsar/pull/21592/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/pulsar/pull/21592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #21592      +/-   ##
   ============================================
   - Coverage     73.35%   73.31%   -0.05%     
   - Complexity    32711    32726      +15     
   ============================================
     Files          1892     1892              
     Lines        140707   140709       +2     
     Branches      15483    15496      +13     
   ============================================
   - Hits         103211   103155      -56     
   - Misses        29394    29446      +52     
   - Partials       8102     8108       +6     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pulsar/pull/21592/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [inttests](https://app.codecov.io/gh/apache/pulsar/pull/21592/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.12% <33.33%> (-0.13%)` | :arrow_down: |
   | [systests](https://app.codecov.io/gh/apache/pulsar/pull/21592/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.64% <33.33%> (-0.42%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pulsar/pull/21592/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.62% <100.00%> (+0.02%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files](https://app.codecov.io/gh/apache/pulsar/pull/21592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...ava/org/apache/pulsar/broker/service/Consumer.java](https://app.codecov.io/gh/apache/pulsar/pull/21592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL0NvbnN1bWVyLmphdmE=) | `86.27% <100.00%> (+0.04%)` | :arrow_up: |
   
   ... and [93 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/21592/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>


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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1399166299


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -351,6 +351,7 @@ public Future<Void> sendMessages(final List<? extends Entry> entries, EntryBatch
                    topicName, subscription, ackedCount, totalMessages, consumerId, avgMessagesPerEntry.get());
         }
         incrementUnackedMessages(unackedMessages);
+        final int finalUnackedMessages = unackedMessages;

Review Comment:
   Suggest to add the logic in the `incrementUnackedMessages`.
   



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "1Jack2 (via GitHub)" <gi...@apache.org>.
1Jack2 commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1410081413


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (subscription.getTopic() instanceof PersistentTopic && Subscription.isIndividualAckMode(subType)) {

Review Comment:
   > yes, could you add a field 'isPersistentTopic' in this class and get this value in the constructor?
   
   Good suggestion, I've changed it, please check again



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "1Jack2 (via GitHub)" <gi...@apache.org>.
1Jack2 commented on PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#issuecomment-1833239652

   /pulsarbot rerun-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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "1Jack2 (via GitHub)" <gi...@apache.org>.
1Jack2 commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1399368271


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -351,6 +351,7 @@ public Future<Void> sendMessages(final List<? extends Entry> entries, EntryBatch
                    topicName, subscription, ackedCount, totalMessages, consumerId, avgMessagesPerEntry.get());
         }
         incrementUnackedMessages(unackedMessages);
+        final int finalUnackedMessages = unackedMessages;

Review Comment:
   > Suggest to add the logic in the `incrementUnackedMessages`.
   
   Good suggestion, 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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "1Jack2 (via GitHub)" <gi...@apache.org>.
1Jack2 commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1400022586


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (Subscription.isIndividualAckMode(subType) && subscription instanceof PersistentSubscription) {

Review Comment:
   > `subscription instanceof PersistentSubscription` or `isDurable` more better ?
   
   `isDurable` is better.



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1406983989


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -1088,7 +1088,7 @@ public Subscription getSubscription() {
 
     private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
         int unackedMsgs = 0;
-        if (Subscription.isIndividualAckMode(subType)) {
+        if (isDurable && Subscription.isIndividualAckMode(subType)) {

Review Comment:
   So we need to check if the topic is persistent.



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


Re: [PR] [fix][broker] Fix incorrect unack count when using shared subscription on non-persistent topic [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21592:
URL: https://github.com/apache/pulsar/pull/21592#discussion_r1410085532


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -239,6 +243,7 @@ public Consumer(Subscription subscription, SubType subType, String topicName, lo
         this.pendingAcks = null;
         this.stats = null;
         this.isDurable = false;
+        this.isPersistentTopic = true;

Review Comment:
   The default value should be `false`.



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