Skip to content

Reader does not return any message when configured with reading inclusive latest messageId #10483

Closed as not planned

Description

@tomjohn9

Describe the bug
Creating reader with messageId pointing to MessageId.latest together with startMessageIdInclusive,there is no message returned when readNext is invoked. Newly coming messages are consumed. When using MessageId.earliest, a message is returned - means there are messages in that topic.

Having running local docker image with puslar 2.7.1 and java client 2.7.1

Steps To Reproduce

pulsarClient.newReader(JSONSchema.of(MySchema.class))
                .topic(topic)
                .startMessageId(MessageId.latest)
                .startMessageIdInclusive().create()
                .readNext(250, TimeUnit.MILLISECONDS)

Expected behavior
Last message in queue is returned when calling Reader.readNext with Reader configuration MessageId.latest and startMessageIdInclusive()

Similar Issue
Seems, it was already reported in issue 4912 in first paragraph Test3

Test3:When configuring Reader with startMessageIdInclusive and positioning stream at MessageId.latest, then the next call to Reader.readNext(timeout) should have returned the last message of the topic, but it times out and returns null (without a configured timeout it blocks forever).
.....
Expected behavior
test3 expected to return the last message in topic, test4 hasMessageAvailable expected to be false.

but it is little bit confusing because underlying method readMessage starts with hasMessageAvailable() which in that time returns wrongly true and readNext is reached but no message is returned, but should be.

Activity

  1. added
    type/bug
    on May 5, 2021
  2. changed the title [-]Reader does not return any message when configured with start with inclusive latest messageId [/-] [+]Reader does not return any message when configured with reading inclusive latest messageId[/+] on May 5, 2021
  3. PatrykWitkowski commented on May 6, 2021

    @PatrykWitkowski

    If you invoke reader.hasMessageAvailable() before reader.readNext() then it works as expected.
    It looks like in that case during searching if there're any messages available a message id for the last message is found and the reader pointer is set for it.
    Logs:

    17:14:42.290 [] [pulsar-client-io-1-1] INFO Get topic last message Id
    17:14:42.290 [] [pulsar-client-io-1-1] INFO Successfully getLastMessageId 150:0
    17:14:42.293 [] [pulsar-client-io-1-1] INFO Seek subscription to message id 150:0:-1
    17:14:42.308 [] [pulsar-client-io-1-1] INFO Successfully reset subscription to message id 150:0:-1
    

    You can use it as a workaround, but still this issue should be fixed.

  4. adrianog commented on May 7, 2021

    @adrianog

    Yes it should be fixed anyway. And please can startMessageIdInclusive be made available to c++/python as well. It is a glaring omission. #10328

  5. added this to the 2.11.0 milestone on Feb 17, 2022
  6. codelipenghui commented on Mar 15, 2022

    @codelipenghui
    Contributor
  7. modified the milestones: 2.11.0, 2.12.0 on Jul 26, 2022
  8. modified the milestones: 3.0.0, 3.1.0 on Apr 11, 2023
  9. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Thanks @tomjohn9 for the report. This was reported on a Pulsar release before 3.0, which is no longer supported; the supported releases are 4.0.x, 4.2.x and 5.0.x. Much of the code involved has changed since, and the problem hasn't been confirmed on a current release, so I'm closing it as part of cleaning up old reports. If you still see it on a supported release, please open a new issue with the version and steps to reproduce, and link this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions