aloyszhang opened a new issue #11825:
URL: https://github.com/apache/pulsar/issues/11825
**Describe the bug**
If AcknowledgmentAtBatchIndexLevelEnabled, consumer may receive duplicated
messages after seek to batchIndex.
**To Reproduce**
Steps to reproduce the behavior:
1. Create producer and enable batch
2. send some message and pick one BatchMessageId
3. create consumer and seek to the BatchMessageId
4. consumer may receive duplicated messages whose MessageId is less than
BatchMessageId
**Expected behavior**
Seek at batchIndex should be take effect.
**Additional context**
Consumer sends a seek request at BatchMessageId, broker processes this
request in two step:
1. disconnect the current consumer, broker sends CommandCloseConsumer
response to consumer
2. resets cursor and sends CommandSuccess response
For consumer:
1. On CommandCloseConsumer, consumer closes the connection and will try
re-connect after a backoff time(default is 100ms). After re-connected, consumer
will `clearReceiverQueue` and get the `startMessageId` which is used for filter
out the messages before the seeked messageId.
```java
if (duringSeek.compareAndSet(true, false)) {
return seekMessageId;
} else if (subscriptionMode == SubscriptionMode.Durable) {
return startMessageId;
}
```
2. On CommandSuccess, consumer will set the `seekMessageId` to the seek
messageId and `duringSeek` to true.
If re-connect happends before consumer receives CommandSuccess, then
`startMessageId` will be not updated by `seekMessageId`, which will cause
message duplication.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]