merlimat commented on a change in pull request #1219: Xzy initialize subscription config URL: https://github.com/apache/incubator-pulsar/pull/1219#discussion_r167657264
########## File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java ########## @@ -2026,6 +2035,23 @@ PositionImpl getMarkDeletePositionOfSlowestConsumer() { return Pair.create(pos, count); } + /** + * Get the first position written in the managed ledger, alongside with the associated counter + */ + Pair<PositionImpl, Long> getFirstPositionAndCounter() { + PositionImpl pos; + long count; + + do { + pos = getFirstPosition(); + count = ENTRIES_ADDED_COUNTER_UPDATER.get(this); Review comment: The backlog count for this subscription will be wrong here. The counter is associated with the last entry written, not with the first one (at least not directly). The correct way to initialize it here would be to: 1. get first position 2. get last position and counter (atomically), though the existing method 3. get number of entries between first and last position (there's method for that) 4. subtract difference from the last position counter value ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services