merlimat opened a new pull request #2047: Fixed resetting of producer sequence id counter after receiving SendError before any message was successfully published URL: https://github.com/apache/incubator-pulsar/pull/2047 ### Motivation There is a combination of events that make the producer to reuse the sequence id on multiple messages: 1. Topic is fenced (eg: by opening ManagedLedger from outside the broker or potentially, by a race condition on ZK lock ownership). 2. Producer connects and try to publish a message 3. The broker gets persistence error since it was fenced and eventually it recovers. 4. When the producer reconnects, the `msgIdGenerator` (which is used to assign sequence ids to messages) is being reset. 5. The first messages (msg-0) was already in the queue and gets finally published 6. The next message (msg-0) is set to use sequence-id 0 as well, since the counter was reset. The `msgIdGenerator` and `lastSequenceIdPublished` only need to be reset with broker values the first time the producer connects, but not in subsequent reconnects. The problem was that by checking `lastSequenceIdPublished` we would see a `-1`, because no message was published successfully, but `msgIdGenerator` was already incremented since we had a message in the queue, and thus it should not be reset. ### Modifications Use `msgIdGenerator` for the check since it will detect when messages where already queued and not successfully acked yet.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
