apache / apache/pulsar-client-python
Reader.has_message_available() returns True when no more messages are available on a compacted topic with tombstone messages
- Ngôn ngữ chính
- Python
- Star
- 75
- Fork
- 53
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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())
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện Python được cung cấp trên một topic đã compact có chứa tombstone, sử dụng Reader.has_message_available() với is_read_compacted=True. Xác nhận rằng reader báo có dữ liệu khả dụng sau khi tất cả các message đã được đọc, sau đó kiểm tra rằng việc thêm một message khác sẽ thay đổi hành vi. Hoàn tất khi method trả về false ngay khi topic đã compact bị đọc hết, kể cả khi có các message tombstone.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- distributed-systems
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100