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/12/13 13:40:36 UTC
[GitHub] [pulsar] AnonHxy opened a new pull request, #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
AnonHxy opened a new pull request, #18911:
URL: https://github.com/apache/pulsar/pull/18911
Fixes https://github.com/apache/pulsar/issues/18910
### Motivation
### Modifications
<!-- Describe the modifications you've done. -->
### Verifying this change
- [x] Make sure that the change passes the CI checks.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
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
[GitHub] [pulsar] congbobo184 commented on a diff in pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#discussion_r1049279897
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -364,7 +357,9 @@ protected Message<T> internalReceive() throws PulsarClientException {
message = incomingMessages.take();
decreaseIncomingMessageSize(message);
checkState(message instanceof TopicMessageImpl);
- unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
+ if (listener == null) {
+ unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
+ }
Review Comment:
seem the listener only use `internalReceive(long timeout, TimeUnit unit)`, change here seems to be unnecessary
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -312,7 +301,9 @@ private void messageReceived(ConsumerImpl<T> consumer, Message<T> message) {
// if asyncReceive is waiting : return message to callback without adding to incomingMessages queue
CompletableFuture<Message<T>> receivedFuture = nextPendingReceive();
if (receivedFuture != null) {
- unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ if (listener == null) {
+ unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ }
Review Comment:
seem the listener only use `internalReceive(long timeout, TimeUnit unit)`, change here seems to be unnecessary
--
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] AnonHxy commented on pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#issuecomment-1352474692
> Will this change influences consumer without a listener?
No, it wouldn't @lifepuzzlefun
--
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 a diff in pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#discussion_r1049279897
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -364,7 +357,9 @@ protected Message<T> internalReceive() throws PulsarClientException {
message = incomingMessages.take();
decreaseIncomingMessageSize(message);
checkState(message instanceof TopicMessageImpl);
- unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
+ if (listener == null) {
+ unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
+ }
Review Comment:
seem the listener only use `nternalReceive(long timeout, TimeUnit unit)`, change here seems to be unnecessary
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -312,7 +301,9 @@ private void messageReceived(ConsumerImpl<T> consumer, Message<T> message) {
// if asyncReceive is waiting : return message to callback without adding to incomingMessages queue
CompletableFuture<Message<T>> receivedFuture = nextPendingReceive();
if (receivedFuture != null) {
- unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ if (listener == null) {
+ unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ }
Review Comment:
seem the listener only use nternalReceive(long timeout, TimeUnit unit), change here seems to be unnecessary
--
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] lifepuzzlefun commented on pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
lifepuzzlefun commented on PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#issuecomment-1351877201
Will this change influences consumer without a listener?
--
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] AnonHxy commented on a diff in pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#discussion_r1051300594
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/ConsumerRedeliveryTest.java:
##########
@@ -262,6 +266,60 @@ public void testConsumerWithPermitReceiveBatchMessages() throws Exception {
log.info("-- Exiting {} test --", methodName);
}
+ @Test(timeOut = 30000)
+ public void testMessageRedeliveryWhenTimeoutInListener() throws Exception {
+ final String subName = "sub_testMessageRedeliveryWhenTimeoutInListener";
+ final String topicName = "testMessageRedeliveryWhenTimeoutInListener" + UUID.randomUUID();
+
+ final int messages = 10;
+
+ @Cleanup
+ Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+ .topic(topicName)
+ .enableBatching(false)
+ .create();
+
+ final String redeliveryMsg = "Hello-0";
+ final AtomicInteger index = new AtomicInteger(0);
+ BlockingQueue<Message<byte[]>> receivedMsgs = new LinkedBlockingQueue<>();
+ MessageListener<byte[]> listener = (consumer, msg) -> {
+ try {
+ // the first msg will wait until timeout
+ if (index.getAndDecrement() == 0 && new String(msg.getData()).equals(redeliveryMsg)) {
+ Thread.sleep(5000);
Review Comment:
Update
--
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] AnonHxy commented on pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#issuecomment-1355988299
@codelipenghui @Technoboy- @HQebupt 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] AnonHxy merged pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
AnonHxy merged PR #18911:
URL: https://github.com/apache/pulsar/pull/18911
--
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] AnonHxy commented on pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#issuecomment-1351334772
@codelipenghui @Technoboy- @HQebupt 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] congbobo184 commented on a diff in pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#discussion_r1049282539
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -312,7 +301,9 @@ private void messageReceived(ConsumerImpl<T> consumer, Message<T> message) {
// if asyncReceive is waiting : return message to callback without adding to incomingMessages queue
CompletableFuture<Message<T>> receivedFuture = nextPendingReceive();
if (receivedFuture != null) {
- unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ if (listener == null) {
+ unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
+ }
Review Comment:
seem the listener only use `internalReceive(long timeout, TimeUnit unit)`, change here seems to be unnecessary
and see a lot of duplicate code
```
if (listener == null) {
unAckedMessageTracker.add(topicMessage.getMessageId(), topicMessage.getRedeliveryCount());
}
```
could you please add a method in ConsumerBase?
--
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] codecov-commenter commented on pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#issuecomment-1355729165
# [Codecov](https://codecov.io/gh/apache/pulsar/pull/18911?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#18911](https://codecov.io/gh/apache/pulsar/pull/18911?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (89836c8) into [master](https://codecov.io/gh/apache/pulsar/commit/3180a4aa04d518fa401a781d646545221c4d1fa6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3180a4a) will **decrease** coverage by `9.16%`.
> The diff coverage is `27.27%`.
[](https://codecov.io/gh/apache/pulsar/pull/18911?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #18911 +/- ##
============================================
- Coverage 46.17% 37.00% -9.17%
+ Complexity 10359 1966 -8393
============================================
Files 703 209 -494
Lines 68845 14406 -54439
Branches 7382 1567 -5815
============================================
- Hits 31788 5331 -26457
+ Misses 33448 8494 -24954
+ Partials 3609 581 -3028
```
| Flag | Coverage Δ | |
|---|---|---|
| unittests | `37.00% <27.27%> (-9.17%)` | :arrow_down: |
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=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18911?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...va/org/apache/pulsar/client/impl/ConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NvbnN1bWVySW1wbC5qYXZh) | `15.09% <0.00%> (-0.03%)` | :arrow_down: |
| [...he/pulsar/client/impl/MultiTopicsConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzQ29uc3VtZXJJbXBsLmphdmE=) | `22.80% <0.00%> (-0.07%)` | :arrow_down: |
| [...va/org/apache/pulsar/client/impl/ProducerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1Byb2R1Y2VySW1wbC5qYXZh) | `16.83% <0.00%> (-0.17%)` | :arrow_down: |
| [...ache/pulsar/client/impl/ZeroQueueConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1plcm9RdWV1ZUNvbnN1bWVySW1wbC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...va/org/apache/pulsar/client/impl/ConsumerBase.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NvbnN1bWVyQmFzZS5qYXZh) | `21.51% <6.66%> (-0.42%)` | :arrow_down: |
| [.../apache/pulsar/client/impl/BatchMessageIdImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0JhdGNoTWVzc2FnZUlkSW1wbC5qYXZh) | `67.50% <100.00%> (-4.73%)` | :arrow_down: |
| [...a/org/apache/pulsar/client/impl/MessageIdImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL01lc3NhZ2VJZEltcGwuamF2YQ==) | `80.85% <100.00%> (+0.29%)` | :arrow_up: |
| [.../apache/pulsar/client/impl/MultiMessageIdImpl.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpTWVzc2FnZUlkSW1wbC5qYXZh) | `80.55% <100.00%> (+7.58%)` | :arrow_up: |
| [.../main/java/org/apache/pulsar/PulsarStandalone.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL1B1bHNhclN0YW5kYWxvbmUuamF2YQ==) | | |
| [...pache/pulsar/broker/admin/v2/PersistentTopics.java](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi92Mi9QZXJzaXN0ZW50VG9waWNzLmphdmE=) | | |
| ... and [493 more](https://codecov.io/gh/apache/pulsar/pull/18911/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
--
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 a diff in pull request #18911: [fix][client] Fix too many redelivered messages when one message acked timeout in listener
Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18911:
URL: https://github.com/apache/pulsar/pull/18911#discussion_r1050836158
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/ConsumerRedeliveryTest.java:
##########
@@ -262,6 +266,60 @@ public void testConsumerWithPermitReceiveBatchMessages() throws Exception {
log.info("-- Exiting {} test --", methodName);
}
+ @Test(timeOut = 30000)
+ public void testMessageRedeliveryWhenTimeoutInListener() throws Exception {
+ final String subName = "sub_testMessageRedeliveryWhenTimeoutInListener";
+ final String topicName = "testMessageRedeliveryWhenTimeoutInListener" + UUID.randomUUID();
+
+ final int messages = 10;
+
+ @Cleanup
+ Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+ .topic(topicName)
+ .enableBatching(false)
+ .create();
+
+ final String redeliveryMsg = "Hello-0";
+ final AtomicInteger index = new AtomicInteger(0);
+ BlockingQueue<Message<byte[]>> receivedMsgs = new LinkedBlockingQueue<>();
+ MessageListener<byte[]> listener = (consumer, msg) -> {
+ try {
+ // the first msg will wait until timeout
+ if (index.getAndDecrement() == 0 && new String(msg.getData()).equals(redeliveryMsg)) {
+ Thread.sleep(5000);
Review Comment:
may be 3000 is enough
--
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