Skip to content

Message deduplication is not well handled when batching is enabled with external provided sequenceId #5476

Closed

Description

@sijie

Describe the bug

Current implementation of Pulsar producer doesn't check the sequenceId when adding messages to a batch container. That results in violations to idempotent producing with external sequenceId.

To Reproduce

  • provide 10 message with sequenceId from 0-9
  • provide 10 message with sequenceId from 0-9 again
  • flush the producer
  • these 20 messages will be received by the consumer

Expected behavior

The second 10 messages will not be added to container, because they are duplicated. We can throw exceptions to client to indicate that it adds out-of-order sequence ids.

Additional context

There are a couple places requires attentions regarding handling batched messages with external sequenceId.

  1. The logic to maintain lastPublishedSequenceId is incorrect when using external sequenceId : lastSequenceIdPublished = op.sequenceId + op.numMessagesInBatch - 1;. Because the last sequence id is an external sequence id, which can't be computed by adding the number of messages in the batch.

  2. We only maintain lastPublishedSequenceId (which is the acked seequence id). We also need to maintain a lastPushSequenceId to indicate the last sequence id that a producer sends to the broker.

  3. the broker need to handle the first sequence id and last sequence id in a message batch.

Activity

  1. added
    type/bug
    on Oct 28, 2019
  2. added this to the 2.4.2 milestone on Oct 28, 2019
  3. added a commit that references this issue on Nov 13, 2019
    d3cb108
  4. modified the milestones: 2.4.2, 2.5.0 on Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/clienttype/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions