lhotari commented on a change in pull request #10755:
URL: https://github.com/apache/pulsar/pull/10755#discussion_r643256205
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
##########
@@ -178,8 +178,21 @@ public void addComplete(int rc, final LedgerHandle lh,
long entryId, Object ctx)
@Override
public void safeRun() {
// Remove this entry from the head of the pending queue
- OpAddEntry firstInQueue = ml.pendingAddEntries.poll();
- checkArgument(this == firstInQueue);
+ OpAddEntry firstInQueue = ml.pollPendingAddEntry();
+ if (this != firstInQueue) {
+ log.warn("Expected OpAddEntry wasn't first in queue. expected={}
actual={}", this, firstInQueue);
+ ManagedLedgerException managedLedgerException =
+ new ManagedLedgerException("Expected OpAddEntry wasn't
first in queue.");
+ // fail both entries
+ try {
+ if (firstInQueue != null) {
+ firstInQueue.failed(managedLedgerException);
+ }
+ } finally {
+ failed(managedLedgerException);
Review comment:
@devinbost there is some logic for that.
https://github.com/apache/pulsar/blob/6a17b3eed6e18e925b133720482ecdaf246e5ef5/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L716-L731
It's a bit hard to understand why the `addOperation` gets added to the
`pendingAddEntries` initially. Why doesn't this happen after the state is
checked? However I consider handling this a separate issue.
In Netty, the contract of reference counted objects is that ["The general
rule of thumb is that the party that accesses a reference-counted object last
is also responsible for the destruction of that reference-counted
object."](https://netty.io/wiki/reference-counted-objects.html#who-destroys-it).
This PR attempts to follow this rule. Therefore I'd suggest that we first
process this PR and file separate issues to fix other problems.
--
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]