-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative acknowledgement doesn't remove the message id from UnAckedMessageTracker when message id is instance of BatchMessageIdImpl #6869
Comments
I wonder if issue #5969 is related. |
@codelipenghui It seems that #6052 was merged to master, however there doesn't seem to be any new logic to properly handle negative acknowledgements when the message id is instance of BatchMessageIdImpl. Perhaps I missed it when I tried to find the way it's fixed. |
@lhotari Thanks for your feedback. Looks #6052 just can avoid the acked messages in the batch message deliver to the consumer. We need to find a way to handle negative acknowledgment. We need to remove the message ID from the unack message tracker and send the redelivery request to the broker until all batch indexes of the batch message are processed(ack or negative ack). |
Hi @codelipenghui , I noticed on Twitter a notice that the release for 2.6.0 will be cut soon. Would it be possible to include a fix in 2.6.0 for this nack & BatchMessageImpl issue? |
Move the task to 2.6.2 |
@lhotari Sorry, I missed your last comment. We will try to fix it on 2.6.2. |
Move this issue to 2.7.0. |
Any updates on this? |
fixed by #9440 |
Describe the bug
The actual symptom was that when using the DLQ feature, the redelivery counts were not consistent in a use case where negative acknowledgements are used. Messages would get redelivered more times than the configured maxRedeliverCount on the DeadLetterPolicy.
I observed this type of log messages in the log output:
By debugging, I noticed that calling
org.apache.pulsar.client.api.Consumer#negativeAcknowledge(org.apache.pulsar.client.api.MessageId)
doesn't remove the message id fromUnAckedMessageTracker
when the message is instance of BatchMessageIdImpl.Expected behavior
org.apache.pulsar.client.impl.UnAckedMessageTracker implementation should encapsulate the fact that the message id must be MessageIdImpl and not BatchMessageIdImpl.
Currently the logic to first convert a BatchMessageIdImpl is done on the calling side (examples:
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Lines 521 to 531 in de57ddd
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Lines 1155 to 1164 in de57ddd
Since the caller has to convert the message id before calling UnAckedMessageTracker add or remove methods, it seems that this leads to error prone usage of the UnAckedMessageTracker class. Currently the conversion to MessageIdImpl is missing in the negative acknowledgement method:
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Lines 556 to 557 in de57ddd
Work around
One workaround is to convert a possible BatchMessageIdImpl to MessageIdImpl before calling the
negativeAcknowledge
method. Something like thisThe text was updated successfully, but these errors were encountered: