mattisonchao opened a new pull request, #15046:
URL: https://github.com/apache/pulsar/pull/15046
### Motivation
According to many PRs flaky-test ``testRedeliveryFailOverConsumer``, the
broker logs as below.
```
2022-04-06T22:02:17,768+0800 [pulsar-io-910-1] INFO
org.apache.pulsar.broker.service.ServerCnx -
[/127.0.0.1:55767][persistent://my-property/my-ns/unacked-topic] Creating
producer. producerId=0
2022-04-06T22:02:17,773+0800 [ForkJoinPool.commonPool-worker-9] INFO
org.apache.pulsar.broker.service.ServerCnx - [/127.0.0.1:55767]
persistent://my-property/my-ns/unacked-topic configured with schema false
2022-04-06T22:02:17,773+0800 [ForkJoinPool.commonPool-worker-9] INFO
org.apache.pulsar.broker.service.ServerCnx - [/127.0.0.1:55767] Created new
producer:
Producer{topic=PersistentTopic{topic=persistent://my-property/my-ns/unacked-topic},
client=/127.0.0.1:55767, producerName=test-0-0, producerId=0}
2022-04-06T22:02:17,774+0800 [pulsar-client-io-938-1] INFO
org.apache.pulsar.client.impl.ProducerImpl -
[persistent://my-property/my-ns/unacked-topic] [test-0-0] Created producer on
cnx [id: 0x92662397, L:/127.0.0.1:55767 - R:localhost/127.0.0.1:55761]
2022-04-06T22:02:17,790+0800 [main] INFO
org.apache.pulsar.client.api.SimpleProducerConsumerTest - Received message:
my-message-0
2022-04-06T22:02:17,790+0800 [main] INFO
org.apache.pulsar.client.api.SimpleProducerConsumerTest - Received message:
my-message-1
2022-04-06T22:02:17,790+0800 [main] INFO
org.apache.pulsar.client.api.SimpleProducerConsumerTest - Received message:
my-message-2
2022-04-06T22:02:17,790+0800 [main] INFO
org.apache.pulsar.client.api.SimpleProducerConsumerTest - Received message:
my-message-3
2022-04-06T22:02:17,791+0800 [broker-topic-workers-OrderedScheduler-8-0]
INFO
org.apache.pulsar.broker.service.persistent.PersistentDispatcherSingleActiveConsumer
- [persistent://my-property/my-ns/unacked-topic /
subscriber-1-Consumer{subscription=PersistentSubscription{topic=persistent://my-property/my-ns/unacked-topic,
name=subscriber-1}, consumerId=0, consumerName=e69eb,
address=/127.0.0.1:55767}] Ignoring reDeliverUnAcknowledgedMessages:
cancelPendingRequest on cursor failed
2022-04-06T22:02:18,795+0800 [main] WARN
org.apache.pulsar.client.impl.ConsumerBase - Consumer filter old epoch message,
topic : [persistent://my-property/my-ns/unacked-topic], messageId : [3:5:-1:0],
messageConsumerEpoch : [0], consumerEpoch : [1]
2022-04-06T22:02:18,795+0800 [main] WARN
org.apache.pulsar.client.impl.ConsumerBase - Consumer filter old epoch message,
topic : [persistent://my-property/my-ns/unacked-topic], messageId : [3:6:-1:0],
messageConsumerEpoch : [0], consumerEpoch : [1]
2022-04-06T22:02:18,796+0800 [main] WARN
org.apache.pulsar.client.impl.ConsumerBase - Consumer filter old epoch message,
topic : [persistent://my-property/my-ns/unacked-topic], messageId : [3:7:-1:0],
messageConsumerEpoch : [0], consumerEpoch : [1]
2022-04-06T22:02:18,796+0800 [main] WARN
org.apache.pulsar.client.impl.ConsumerBase - Consumer filter old epoch message,
topic : [persistent://my-property/my-ns/unacked-topic], messageId : [3:8:-1:0],
messageConsumerEpoch : [0], consumerEpoch : [1]
2022-04-06T22:02:18,796+0800 [main] WARN
org.apache.pulsar.client.impl.ConsumerBase - Consumer filter old epoch message,
topic : [persistent://my-property/my-ns/unacked-topic], messageId : [3:9:-1:0],
messageConsumerEpoch : [0], consumerEpoch : [1]
```
> Ignoring reDeliverUnAcknowledgedMessages: cancelPendingRequest on cursor
failed
Relative code:
https://github.com/apache/pulsar/blob/81da8d3cd199fd6c1e4510a1c1c2ac71418efd5e/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java#L317-L328
https://github.com/apache/pulsar/blob/81da8d3cd199fd6c1e4510a1c1c2ac71418efd5e/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java#L136-L141
https://github.com/apache/pulsar/blob/81da8d3cd199fd6c1e4510a1c1c2ac71418efd5e/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L847-L851
When ``cursor.cancelPendingReadRequest()`` returns false the cursor will not
rewind, then `reDeliverUnAcknowledgedMessages` will fail. Causes the message to
not be redelivered.
### Modifications
- Make ``cancelPendingRead`` always successful.
### Verifying this change
- [x] Make sure that the change passes the CI checks.
Existing test ``testRedeliveryFailOverConsumer`` cover this issue.
### Documentation
- [x] `no-need-doc`
--
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]