You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "aloyszhang (via GitHub)" <gi...@apache.org> on 2023/02/21 11:27:08 UTC
[GitHub] [pulsar] aloyszhang opened a new pull request, #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
aloyszhang opened a new pull request, #19581:
URL: https://github.com/apache/pulsar/pull/19581
### Motivation
There're some cases of consumers receiving duplicated messages when there are ongoing transactions within a subscription.
#14327 has fixed this problem partially. But there's still a chance for consumers to receive duplicated messages.
1. For non-batch messages, the dispatcher does not filter messages in the pendingAck state(PendingAckHandleImpl#individualAckPositions)
2. For batch messages, if the ackSet in pendingAck state is complimentary with the ackSet in the cursor(the result of the two ackSet AND is empty), the broker still dispatches this entry to the consumer. For example, a batch message has 5 messages internal.
- cursor stats has acked 0,1,2
- pendingAck stats has acked 3,4
This message should not dispatch to the consumer.
### Modifications
1. filter messages in pendingAck for non-batch messages
2. filter messages ackSet in pendingAck state is complimentary with the ackSet in the cursor for batch messages
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
### Documentation
- [ ] `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] aloyszhang commented on a diff in pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#discussion_r1113136851
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/PositionAckSetUtil.java:
##########
@@ -59,6 +59,11 @@ public static long[] andAckSet(long[] firstAckSet, long[] secondAckSet) {
return ackSet;
}
+ public static boolean isAckSetEmpty(long[] ackSet) {
+ BitSetRecyclable bitSet = BitSetRecyclable.create().resetWords(ackSet);
Review Comment:
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
[GitHub] [pulsar] coderzc commented on pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#issuecomment-1451613110
@aloyszhang Can you help cherry-pick this PR to branch-2.9?
--
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] michaeljmarshall commented on pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "michaeljmarshall (via GitHub)" <gi...@apache.org>.
michaeljmarshall commented on PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#issuecomment-1610271924
As discussed on the mailing list https://lists.apache.org/thread/w4jzk27qhtosgsz7l9bmhf1t7o9mxjhp, there is no plan to release 2.9.6, so I am going to remove the release/2.9.6 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] aloyszhang commented on a diff in pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#discussion_r1114222536
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -239,6 +240,21 @@ public int filterEntriesForConsumer(@Nullable MessageMetadata[] metadataArray, i
// if actSet is null, use pendingAck ackSet
ackSet = positionInPendingAck.getAckSet();
}
+ // if the result of pendingAckSet(in pendingAckHandle) AND the ackSet(in cursor) is empty
+ // filter this entry
+ if (isAckSetEmpty(ackSet)) {
+ entries.set(i, null);
+ entry.release();
+ continue;
+ }
+ } else {
+ // filter non-batch message in pendingAck state
+ if (positionInPendingAck.getLedgerId() == entry.getLedgerId()
+ && positionInPendingAck.getEntryId() == entry.getEntryId()) {
+ entries.set(i, null);
Review Comment:
You're right. 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
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#discussion_r1114093804
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -239,6 +240,21 @@ public int filterEntriesForConsumer(@Nullable MessageMetadata[] metadataArray, i
// if actSet is null, use pendingAck ackSet
ackSet = positionInPendingAck.getAckSet();
}
+ // if the result of pendingAckSet(in pendingAckHandle) AND the ackSet(in cursor) is empty
+ // filter this entry
+ if (isAckSetEmpty(ackSet)) {
+ entries.set(i, null);
+ entry.release();
+ continue;
+ }
+ } else {
+ // filter non-batch message in pendingAck state
+ if (positionInPendingAck.getLedgerId() == entry.getLedgerId()
+ && positionInPendingAck.getEntryId() == entry.getEntryId()) {
+ entries.set(i, null);
Review Comment:
`if (positionInPendingAck.getLedgerId() == entry.getLedgerId() && positionInPendingAck.getEntryId() == entry.getEntryId())`
This check is unnecessary, right?
--
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 #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#issuecomment-1455411772
Due to #14327 be moved 2.9.6, so this PR also move to 2.9.6
--
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 #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "congbobo184 (via GitHub)" <gi...@apache.org>.
congbobo184 commented on code in PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#discussion_r1113077721
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/PositionAckSetUtil.java:
##########
@@ -59,6 +59,11 @@ public static long[] andAckSet(long[] firstAckSet, long[] secondAckSet) {
return ackSet;
}
+ public static boolean isAckSetEmpty(long[] ackSet) {
+ BitSetRecyclable bitSet = BitSetRecyclable.create().resetWords(ackSet);
Review Comment:
please recycle this bitSet or use `BitSetRecyclable.valueOf()`
--
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] aloyszhang merged pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang merged PR #19581:
URL: https://github.com/apache/pulsar/pull/19581
--
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 #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#issuecomment-1439516496
# [Codecov](https://codecov.io/gh/apache/pulsar/pull/19581?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 [#19581](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (84f42a3) into [master](https://codecov.io/gh/apache/pulsar/commit/e0b50c9ec5f12d0fb8275f235d8ac00e87a9099e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e0b50c9) will **increase** coverage by `37.18%`.
> The diff coverage is `84.61%`.
[](https://codecov.io/gh/apache/pulsar/pull/19581?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 #19581 +/- ##
=============================================
+ Coverage 24.65% 61.84% +37.18%
- Complexity 291 3491 +3200
=============================================
Files 1591 1844 +253
Lines 123073 135299 +12226
Branches 13434 14879 +1445
=============================================
+ Hits 30348 83671 +53323
+ Misses 88233 43889 -44344
- Partials 4492 7739 +3247
```
| Flag | Coverage Δ | |
|---|---|---|
| inttests | `24.78% <0.00%> (+0.12%)` | :arrow_up: |
| systests | `25.25% <0.00%> (?)` | |
| unittests | `59.01% <84.61%> (?)` | |
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/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../pulsar/broker/service/AbstractBaseDispatcher.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL0Fic3RyYWN0QmFzZURpc3BhdGNoZXIuamF2YQ==) | `68.04% <77.77%> (+25.33%)` | :arrow_up: |
| [...he/bookkeeper/mledger/util/PositionAckSetUtil.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci91dGlsL1Bvc2l0aW9uQWNrU2V0VXRpbC5qYXZh) | `83.72% <100.00%> (+37.56%)` | :arrow_up: |
| [...ce/ConsistentHashingStickyKeyConsumerSelector.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL0NvbnNpc3RlbnRIYXNoaW5nU3RpY2t5S2V5Q29uc3VtZXJTZWxlY3Rvci5qYXZh) | `76.92% <0.00%> (-3.85%)` | :arrow_down: |
| [...in/java/org/apache/pulsar/common/api/AuthData.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jb21tb24vYXBpL0F1dGhEYXRhLmphdmE=) | `71.42% <0.00%> (ø)` | |
| [.../apache/pulsar/broker/namespace/LookupOptions.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9uYW1lc3BhY2UvTG9va3VwT3B0aW9ucy5qYXZh) | `87.50% <0.00%> (ø)` | |
| [.../apache/pulsar/common/naming/SystemTopicNames.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NvbW1vbi9uYW1pbmcvU3lzdGVtVG9waWNOYW1lcy5qYXZh) | `55.55% <0.00%> (ø)` | |
| [...apache/pulsar/common/util/SafeCollectionUtils.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NvbW1vbi91dGlsL1NhZmVDb2xsZWN0aW9uVXRpbHMuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...pache/pulsar/common/configuration/BindAddress.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jb21tb24vY29uZmlndXJhdGlvbi9CaW5kQWRkcmVzcy5qYXZh) | `22.22% <0.00%> (ø)` | |
| [...r/client/admin/internal/data/AuthPoliciesImpl.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9hZG1pbi9pbnRlcm5hbC9kYXRhL0F1dGhQb2xpY2llc0ltcGwuamF2YQ==) | `65.21% <0.00%> (ø)` | |
| [...sar/common/policies/data/impl/BundlesDataImpl.java](https://codecov.io/gh/apache/pulsar/pull/19581?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC1hZG1pbi1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jb21tb24vcG9saWNpZXMvZGF0YS9pbXBsL0J1bmRsZXNEYXRhSW1wbC5qYXZh) | `92.30% <0.00%> (ø)` | |
| ... and [1369 more](https://codecov.io/gh/apache/pulsar/pull/19581?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] github-actions[bot] commented on pull request #19581: [fix][txn]fix receive duplicated messages due to pendingAcks in PendingAckHandle
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19581:
URL: https://github.com/apache/pulsar/pull/19581#issuecomment-1438317824
@aloyszhang Please add the following content to your PR description and select a checkbox:
```
- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `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