Repository navigation
Description
Describe the bug
Broker throws IllegalArgumentException on write failures.
java.lang.IllegalArgumentException: ledgerId 40 doesn't match with acked ledgerId 39
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:323) ~[com.google.guava-guava-21.0.jar:?]
at org.apache.bookkeeper.mledger.impl.OpAddEntry.addComplete(OpAddEntry.java:116) ~[org.apache.pulsar-managed-ledger-original-2.4.1.jar:2.4.1]
at org.apache.bookkeeper.client.AsyncCallback$AddCallback.addCompleteWithLatency(AsyncCallback.java:91) ~[org.apache.bookkeeper-bookkeeper-server-4.9.2.jar:4.9.2]
at org.apache.bookkeeper.client.PendingAddOp.submitCallback(PendingAddOp.java:390) ~[org.apache.bookkeeper-bookkeeper-server-4.9.2.jar:4.9.2]
at org.apache.bookkeeper.client.LedgerHandle.errorOutPendingAdds(LedgerHandle.java:1772) ~[org.apache.bookkeeper-bookkeeper-server-4.9.2.jar:4.9.2]
at org.apache.bookkeeper.client.LedgerHandle$5.safeRun(LedgerHandle.java:572) ~[org.apache.bookkeeper-bookkeeper-server-4.9.2.jar:4.9.2]
at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) [org.apache.bookkeeper-bookkeeper-common-4.9.2.jar:4.9.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-all-4.1.32.Final.jar:4.1.32.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
To Reproduce
Has seen this behavior on several stress tests.
Expected behavior
No exception throw during stress tests.
Additional context
The problem was introduced because we reuse OpAddEntry between two different ledgers.
- when a ledger fails to write an entry, the ledger is closed. but we didn't clear
pendingAddEntriesin managed ledger. (https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java#L228) - when a new ledger is opened, the
pendingAddEntrieswill be re-sent by setting to the new ledger handle. (https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1299)
If the callback of an OpAddEntry is triggered after the op is already re-sent to the new ledger, it will check if the ledger id in the callback is same as the ledger id in the OpAddEntry is same. If the ledger doesn't match, it will throw IllegalArgumentException (https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java#L179)
Since we are using recycler for managing OpAddEntry, we should avoid using same ops between different ledger handles.
Activity