You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Batched messages are dropped by broker deduplication when a delayed message is sent while the batch is pending #615
I searched in the issues and found nothing similar.
Version
main (f71d7e9), also 4.1.0 (bundled by pulsar-client-node 1.17.0)
Minimal reproduce step
Enable deduplication on a namespace (brokerDeduplicationEnabled=true, or POST /admin/v2/namespaces/{tenant}/{ns}/deduplication true).
Create a producer with batching enabled (default or key based batching).
Send some messages asynchronously, so they wait in the batch container.
Before the batch is flushed, send a message with setDeliverAfter / setDeliverAt.
Read the topic from the earliest position.
What did you expect to see?
All messages are stored.
What did you see instead?
Only the delayed message is stored. The batched messages are acknowledged to the producer (ResultOk) but the broker drops them as duplicates.
Anything else?
ProducerImpl::sendAsync assigns the sequence id before deciding whether the message can be batched. A message with a delivery time cannot be batched, so it is sent right away with a sequence id greater than the ones of the messages still waiting in the batch container. The broker persists it first, records it as the highest sequence id of the producer, and then drops the batch, whose sequence ids are lower, as a duplicate.
The Java client does not have this issue: ProducerImpl#processOpSendMsg calls batchMessageAndSend(false) before sending any non-batched message, so the broker receives the sequence ids in order.
Activity