You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/07 05:11:24 UTC
[GitHub] [pulsar] aloyszhang commented on a diff in pull request #16420: [fix][broker] fix No such ledger exception
aloyszhang commented on code in PR #16420:
URL: https://github.com/apache/pulsar/pull/16420#discussion_r915464235
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -1482,18 +1482,17 @@ public synchronized void createComplete(int rc, final LedgerHandle lh, Object ct
lastLedgerCreationFailureTimestamp = clock.millis();
} else {
log.info("[{}] Created new ledger {}", name, lh.getId());
- ledgers.put(lh.getId(), LedgerInfo.newBuilder().setLedgerId(lh.getId()).setTimestamp(0).build());
- currentLedger = lh;
- currentLedgerEntries = 0;
- currentLedgerSize = 0;
-
final MetaStoreCallback<Void> cb = new MetaStoreCallback<Void>() {
@Override
public void operationComplete(Void v, Stat stat) {
if (log.isDebugEnabled()) {
log.debug("[{}] Updating of ledgers list after create complete. version={}", name, stat);
}
ledgersStat = stat;
+ ledgers.put(lh.getId(), LedgerInfo.newBuilder().setLedgerId(lh.getId()).setTimestamp(0).build());
Review Comment:
Agree with @mattisonchao. This may lead to data loss.
Putting the newly created ledger into the `NavigableMap<Long, LedgerInfo> ledgers`, the new ledger can be seen immediately which means can write data into this ledger, and then if the meta-store operation failed, the ledger will be removed from both the `ledgers` and bookie, all data in this ledger are lost.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org