poorbarcode commented on code in PR #24722:
URL: https://github.com/apache/pulsar/pull/24722#discussion_r2339477436
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -1878,10 +1878,38 @@ protected synchronized void
updateLedgersIdsComplete(@Nullable LedgerHandle orig
}
}
+ void ledgerAddFailedDueToConcurrentlyModified(final LedgerHandle
currentLedger) {
+ bookKeeper.asyncOpenLedger(currentLedger.getId(), digestType,
config.getPassword(), (rc, lh, ctx) -> {
+ if (rc == Code.OK) {
+ log.warn("[{}] Successfully opened ledger {} to check the last
add confirmed position when the ledger"
+ + " was concurrent modified(it is an unexpected behaviour,
which happens when the load-balancer"
+ + " does not work as expected). The add confirmed position
in memory is {}, and the value"
+ + " stored in metadata store is {}. When you get this log,
the latest several entries may be"
+ + " repeated.", name, lh.getId(),
currentLedger.getLastAddConfirmed(), lh.getLastAddConfirmed());
+ ledgerClosed(currentLedger, lh.getLastAddConfirmed());
+ } else {
+ log.error("[{}] Going to fence the topic because failed opened
ledger {} to check the last add"
+ + " confirmed position when the ledger was concurrent
modified(it is an unexpected behaviour,"
+ + " which happens when the load-balancer does not work
as expected). The add confirmed position"
+ + " in memory is {}, and the error code {}. Fecing the
topic to avoid messages lost.",
+ name, lh.getId(), currentLedger.getLastAddConfirmed(),
rc);
+ // Stop switching ledger and write topic metadata, to avoid
messages lost. The doc of
+ // LedgerHandle also mentioned this:
https://github.com/apache/bookkeeper/blob/release-4.17.2/
+ //
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java#L2047-L2048
Review Comment:
> Due to similar reasons as https://github.com/apache/pulsar/pull/24665, is
it really reliable?
They are not related.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]