Skip to content

[Bug] Batched messages are dropped by broker deduplication when a delayed message is sent while the batch is pending #615

Open

Description

@gusteycamargo

Search before asking

  • 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

  1. Enable deduplication on a namespace (brokerDeduplicationEnabled=true, or POST /admin/v2/namespaces/{tenant}/{ns}/deduplication true).
  2. Create a producer with batching enabled (default or key based batching).
  3. Send some messages asynchronously, so they wait in the batch container.
  4. Before the batch is flushed, send a message with setDeliverAfter / setDeliverAt.
  5. 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.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions