golden-yang opened a new issue #12421:
URL: https://github.com/apache/pulsar/issues/12421
**Describe the bug**
We have a topic that has not been updated with new message for a month.
When I use PulsarReader.getLastMessageIdAsync, This method will always be
blocked.
It happen in pulsar 2.6.1, I am not sure if this has been fixed.
In pulsar broker log, I found these log:
> 2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.pulsar.broker.service.ServerCnx - [/*.*.*.*:60958] Subscribing on
topic persistent://d***ub/s**am/18182_*****_offset / reader-0c132b75a4
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.pulsar.broker.service.persistent.PersistentTopic -
[persistent://d***ub/s**am/18182_*****_offset][reader-0c132b75a4] Creating
non-durable subscription at msg id -1: -1: -1: -1
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.bookkeeper.mledger.impl.NonDurableCursorImpl -
[d***ub/s**am/persistent/18182_*****_offset] Created non-durable cursor
read-position=5540818:0 mark-delete-position=5540818:-1
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl -
[d***ub/s**am/persistent/18182_*****_offset] Opened new cursor:
NonDurableCursorImpl{ledger=d***ub/s**am/persistent/18182_*****_offset,
ackPos=5540818:-1, readPos=5540818:0}
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.bookkeeper.mledger.impl.ManagedCursorImpl -
[d***ub/s**am/persistent/18182_*****_offset-reader-0c132b75a4] Rewind from
5540818:0 to 5540818:0
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.pulsar.broker.service.persistent.PersistentTopic -
[persistent://d***ub/s**am/18182_*****_offset] There are no replicated
subscriptions on the topic
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.pulsar.broker.service.persistent.PersistentTopic -
[persistent://d***ub/s**am/18182_*****_offset][reader-0c132b75a4] Created new
subscription for 0
2021-10-19 17:07:35.190 [pulsar-io-23-68] INFO
org.apache.pulsar.broker.service.ServerCnx - [/*.*.*.*:60958] Created
subscription on topic persistent://d***ub/s**am/18182_*****_offset /
reader-0c132b75a4
2021-10-19 17:07:35.193 [bookkeeper-ml-workers-OrderedExecutor-4-0] ERROR
org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl -
[d***ub/s**am/persistent/18182_*****_offset] Error opening ledger for reading
at position 5540818:58 -
org.apache.bookkeeper.mledger.ManagedLedgerException$NonRecoverableLedgerException:
No such ledger exists on Metadata Server
I think getLastMessageIdAsync method will be blocked, when BK ledger is been
cleaned.
Metadata for broker may be different from metadata for bookie.
But this should not throw an exception directly, without telling the client.
Topic internalStats API show that:
> {
"entriesAddedCounter": 129,
"numberOfEntries": 0,
"totalSize": 0,
"currentLedgerEntries": 0,
"currentLedgerSize": 0,
"lastLedgerCreatedTimestamp": "2021-04-16T06:37:18.234+08:00",
"waitingCursorsCount": 0,
"pendingAddEntriesCount": 0,
"lastConfirmedEntry": "5540818:58",
"state": "LedgerOpened",
"ledgers": [
{
"ledgerId": 5547722,
"entries": 0,
"size": 0,
"offloaded": false
}
],
"cursors": {
"reader-0c132b75a4": {
"markDeletePosition": "5540818:-1",
"readPosition": "5540818:0",
"waitingReadOp": false,
"pendingReadOps": 1,
"messagesConsumedCounter": 70,
"cursorLedger": -1,
"cursorLedgerLastEntry": -1,
"individuallyDeletedMessages": "[]",
"lastLedgerSwitchTimestamp": "2021-10-19T17:07:35.19+08:00",
"state": "Uninitialized",
"numberOfEntriesSinceFirstNotAckedMessage": 1,
"totalNonContiguousDeletedMessagesRange": 0,
"properties": {
}
}
}
**To Reproduce**
Steps to reproduce the behavior:
1. create topic, write message, make message expire
2. create Reader for this topict
3. use getLastMessageId(). It will never been active.
**Expected behavior**
The client can clearly obtain the information when the message has expired
or there is a problem with the server。
** VERSION **
pulsar 2.6.1
--
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]