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/10/21 12:55:03 UTC
[GitHub] [pulsar] lordcheng10 opened a new pull request, #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
lordcheng10 opened a new pull request, #18154:
URL: https://github.com/apache/pulsar/pull/18154
### Motivation
In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal:
https://github.com/apache/pulsar/blob/fa328a42d5770a27237d926eac97385284876174/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L660-L669
### Modifications
When the messageId is equal, but the batch index is larger, the bitSetRecyclable should be updated:
```
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
if (messageId.equals(this.messageId)) {
if (this.bitSetRecyclable != null && bitSetRecyclable != null
&& bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
this.bitSetRecyclable.recycle();
set(messageId, bitSetRecyclable);
flushRequired = true;
}
return;
}
if (messageId.compareTo(this.messageId) > 0) {
if (this.bitSetRecyclable != null && this.bitSetRecyclable != bitSetRecyclable) {
this.bitSetRecyclable.recycle();
}
set(messageId, bitSetRecyclable);
flushRequired = true;
}
}
```
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
- [ ] `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 -->
<!--
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] Jason918 commented on a diff in pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
Jason918 commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1002338700
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
private boolean flushRequired = false;
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
+ if (messageId.equals(this.messageId)) {
+ if (this.bitSetRecyclable != null && bitSetRecyclable != null
+ && bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
+ this.bitSetRecyclable.recycle();
+ set(messageId, bitSetRecyclable);
+ flushRequired = true;
+ }
+ return;
+ }
+
if (messageId.compareTo(this.messageId) > 0) {
Review Comment:
+1
--
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] lordcheng10 closed pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
lordcheng10 closed pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
URL: https://github.com/apache/pulsar/pull/18154
--
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] BewareMyPower commented on a diff in pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1001833223
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
private boolean flushRequired = false;
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
+ if (messageId.equals(this.messageId)) {
+ if (this.bitSetRecyclable != null && bitSetRecyclable != null
+ && bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
+ this.bitSetRecyclable.recycle();
+ set(messageId, bitSetRecyclable);
+ flushRequired = true;
+ }
+ return;
+ }
+
if (messageId.compareTo(this.messageId) > 0) {
Review Comment:
+1
--
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] BewareMyPower commented on a diff in pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1001821538
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
private boolean flushRequired = false;
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
+ if (messageId.equals(this.messageId)) {
+ if (this.bitSetRecyclable != null && bitSetRecyclable != null
+ && bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
+ this.bitSetRecyclable.recycle();
+ set(messageId, bitSetRecyclable);
+ flushRequired = true;
+ }
+ return;
+ }
+
if (messageId.compareTo(this.messageId) > 0) {
Review Comment:
We already have the compare sult, I think we can improve it like
```java
int compareResult = messageId.compareTo(this.messageId);
if (messageId.compareTo(this.messageId) > 0) {
/* ... */
} else if (compareResult == 0) {
/* compare bitSetRecyclable... */
}
```
--
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] lordcheng10 commented on pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#issuecomment-1287052261
> If `messageId.equals(this.messageId)`, it must means `this.messageId` has the same batch index with `messageId`.
Yes,you are right!
Can the bitSetRecyclable variable be removed? Because we can know which sub-messages have been acknowledged just by the batch index:@BewareMyPower
<img width="1046" alt="image" src="https://user-images.githubusercontent.com/19296967/197221021-4331834d-1b4c-4aa7-b888-c20cd4236285.png">
--
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] lordcheng10 commented on a diff in pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1001840723
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
private boolean flushRequired = false;
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
+ if (messageId.equals(this.messageId)) {
+ if (this.bitSetRecyclable != null && bitSetRecyclable != null
+ && bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
+ this.bitSetRecyclable.recycle();
+ set(messageId, bitSetRecyclable);
+ flushRequired = true;
+ }
+ return;
+ }
+
if (messageId.compareTo(this.messageId) > 0) {
Review Comment:
Yes, you are 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] lordcheng10 commented on pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#issuecomment-1287046881
> If `messageId.equals(this.messageId)`, it must means `this.messageId` has the same batch index with `messageId`.
Yes,you are 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] congbobo184 commented on a diff in pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1001827854
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
private boolean flushRequired = false;
public synchronized void update(final MessageIdImpl messageId, final BitSetRecyclable bitSetRecyclable) {
+ if (messageId.equals(this.messageId)) {
+ if (this.bitSetRecyclable != null && bitSetRecyclable != null
+ && bitSetRecyclable.nextSetBit(0) > this.bitSetRecyclable.nextSetBit(0)) {
+ this.bitSetRecyclable.recycle();
+ set(messageId, bitSetRecyclable);
+ flushRequired = true;
+ }
+ return;
+ }
+
if (messageId.compareTo(this.messageId) > 0) {
Review Comment:
seem compareTo has already compare the batchIndex. https://github.com/apache/pulsar/blob/fa328a42d5770a27237d926eac97385284876174/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageIdImpl.java#L248-L253 so we don't need to do single check, 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] lordcheng10 commented on pull request #18154: [fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.
Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#issuecomment-1286950365
@Technoboy- @Jason918 @BewareMyPower @AnonHxy @codelipenghui PTAL,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