[
https://issues.apache.org/jira/browse/BOOKKEEPER-162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203358#comment-13203358
]
Flavio Junqueira commented on BOOKKEEPER-162:
---------------------------------------------
Agreed, it shouldn't return 0 when the ledger is empty. In the case the ledger
has one element, it should still return -1 (empty) according to the semantics
of the call. readLastConfirmed returns the maximum hint across all bookies, and
the hint for a ledger is the value of the last confirmed field in the last
entry it wrote. Consequently, if there is only one entry written, the hint will
say that there is no add confirmed before that one, which is correct.
Perhaps if you need to know precisely which entries have been confirmed, you
may want to have the writer communicating to the readers though ZooKeeper or
directly (e.g., TCP). The readLastConfirmed mechanism gives an approximation of
the state of the ledger, and is particularly useful when writing streams
continuously.
If you can say more about your use case, we may be able to help you decide,
Philipp.
> LedgerHandle.readLastConfirmed does not work
> --------------------------------------------
>
> Key: BOOKKEEPER-162
> URL: https://issues.apache.org/jira/browse/BOOKKEEPER-162
> Project: Bookkeeper
> Issue Type: Bug
> Components: bookkeeper-client
> Affects Versions: 4.0.0
> Reporter: Philipp Sushkin
> Assignee: Flavio Junqueira
> Priority: Critical
> Fix For: 4.0.0
>
> Attachments: BOOKKEEPER-162.patch, BOOKKEEPER-162.patch,
> BOOKKEEPER-162.patch, BookieReadWriteTest.java.patch,
> BookieReadWriteTest.java.patch, BookieReadWriteTest.java.patch, bookkeeper.log
>
>
> Two bookkeeper clients.
> 1st continuously writing to ledger X.
> 2nd (bk.openLedgerNoRecovery) polling ledger X for new entries and reading
> them.
> In response we always reveiceing 0 as last confirmed entry id (in fact we are
> receiving -1 from each bookie RecoveryData but then in ReadLastConfirmedOp,
> but uninitialized "long maxAddConfirmed;" takes priority in Math.max(...).
> Main question - is given scenario is expected to work at all?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira