-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix batch ackset recycled multiple times. #7409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| public void recycle() { | ||
| if (recyclerHandle != null) { | ||
| if (recyclerHandle != null && recycled.compareAndSet(false, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not safe. There cannot be a race condition to resolve the recycling.
In this case it can happen:
thread-1calls recycle and CAS succeedsthread-2gets a the object from poolthread-3seesrecycled==falseand does the CAS again, recycle a different object that is in use.
You cannot use Recyclable for objects with a shared ownership. Either change the logic to avoid race conditions, or use ref-counting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merlimat I have addressed your comments, please take a look again, thanks.
|
/pulsarbot run-failure-checks |
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java
Outdated
Show resolved
Hide resolved
…ections/BitSetRecyclable.java
|
/pulsarbot run-failure-checks |
* Fix batch ackset recycled multiple times. * Apply comments. * Update pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java (cherry picked from commit 25a6907)
* Fix batch ackset recycled multiple times. * Apply comments. * Update pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java
* Fix batch ackset recycled multiple times. * Apply comments. * Update pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java
* Fix batch ackset recycled multiple times. * Apply comments. * Update pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java (cherry picked from commit 25a6907)
* Fix batch ackset recycled multiple times. * Apply comments. * Update pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java
Fixes #7384
Motivation
Fix batch ackset recycled multiple times. The root cause is a race condition in group ack flush and cumulative Ack. So add recycled state check for the ackset.
Verifying this change
New unit test added.
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation