hangc0276 commented on code in PR #3917:
URL: https://github.com/apache/bookkeeper/pull/3917#discussion_r1168080849
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragment.java:
##########
@@ -53,8 +53,13 @@ public LedgerFragment(LedgerHandle lh,
this.schedule = lh.getDistributionSchedule();
SortedMap<Long, ? extends List<BookieId>> ensembles = lh
.getLedgerMetadata().getAllEnsembles();
+ // Check if the ledger fragment is closed has two conditions
+ // 1. The ledger is closed
+ // 2. This fragment is not the last fragment and this ledger's
lastAddConfirm >= ensembles.lastKey() - 1.
+ // This case happens when the ledger's last ensemble is empty
this.isLedgerClosed = lh.getLedgerMetadata().isClosed()
- || !ensemble.equals(ensembles.get(ensembles.lastKey()));
+ || (!ensemble.equals(ensembles.get(ensembles.lastKey()))
+ && lh.getLastAddConfirmed() >= ensembles.lastKey() - 1);
Review Comment:
Maybe not. Take the following case for example:
0: [bk1, bk2, bk3]
10: [bk1, bk2, bk4]
LAC = 100
Ledger is OPEN
For the first ensemble: isLedgerClosed = (false || (true && 100 >= 9)) =>
true
For the last ensemble: isLedgerClosed = (false || (false && 100 >= 9)) =>
false
The result is expected.
--
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]