apache / apache/pulsar-client-python
Reader.has_message_available() returns True when no more messages are available on a compacted topic with tombstone messages
- 主要语言
- Python
- 星标
- 75
- 派生
- 53
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
```python
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.
```python
producer.send(
b'message3',
partition_key="3",
)
while reader.has_message_available():
msg = reader.read_next()
print(msg.data())
```
贡献指南
调研方向
首先,针对包含 tombstone 的压缩 topic,使用带有 is_read_compacted=True 的 Reader.has_message_available() 运行提供的 Python 复现。确认读取完所有消息后 reader 仍报告有可用消息,然后验证添加另一条消息会改变行为。当压缩 topic 耗尽后 method 返回 false(包括存在 tombstone 消息的情况)即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- distributed-systems
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100