lhotari commented on a change in pull request #10480:
URL: https://github.com/apache/pulsar/pull/10480#discussion_r627400020
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryImpl.java
##########
@@ -166,7 +170,16 @@ protected void deallocate() {
timestamp = -1;
ledgerId = -1;
entryId = -1;
+ invalidated.set(false);
recyclerHandle.recycle(this);
}
+ @Override
+ public boolean invalidate() {
+ if (invalidated.compareAndSet(false, true)) {
+ release();
+ return true;
+ }
+ return false;
Review comment:
> This will avoid decrementing the ref-count more than once, but it will
not prevent the 2nd thread from accessing an entry whose ref-count was already
to 0.
Yes, that's a good point. I'm thinking of a solution where invalidation
would be a completely separate operation which triggers when reference count is
1 or gets back to 1. Another protection here would be a change in logic that
release operations to change reference count from 1 to 0 would be rejected
completely. That would prevent bugs which are caused by release being called
too many times. Those issues could be logged and fixed if such bugs exist.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]