Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader.has_message_available() returns True when no more messages are available on a compacted topic with tombstone messages #221

Open
telnoratti opened this issue Aug 26, 2024 · 0 comments

Comments

@telnoratti
Copy link

When reading a compacted topic with is_read_compacted=True has_message_available returns true even after all messages have been read when there is a tombstone message. This might be related to #199. As soon as any messages are added after compaction it behaves correctly again.

Python 3.12.4
pulsar-client 3.5.0

url = "localhost"
topic = "tenant/namespace/topic"
client = pulsar.Client(pulsar_url)

producer = client.create_producer(topic)
producer.send(
    b'message',
    partition_key="1",
)
# tombstone message
producer.send(
    b'',
    partition_key="1",
)
# If there is only the tombstone message, then it returns False, presumably because the compacted topic is empty
producer.send(
    b'message2',
    partition_key="2",
)

# compact the topic here with "bin/pulsar-admin topics compact tenant/namespace/topic"

reader = client.create_reader(
    topic=topic,
    start_message_id=pulsar.MessageId.earliest,
    is_read_compacted=True,
)

while reader.has_message_available():
    msg = reader.read_next()
    print(msg.data())

Once another message has been sent, the reader operates correctly again.

producer.send(
    b'message3',
    partition_key="3",
)
while reader.has_message_available():
    msg = reader.read_next()
    print(msg.data())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant