[Bug] ack doesn't work after changeInvisibleDuration
Before Creating the Bug Report
-
[x] I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
[x] I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
[x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
RocketMQ Nameserver, Broker, Proxy ran in linux container with Podman Desktop on MacOS. Client ran on MacOS.
RocketMQ version
Broker 5.3.3, Client Java SDK 5.0.8.
JDK Version
JDK 21 Temurin-21.0.4+7
Describe the Bug
In particular sequence of operations, ack would not take effect nor throw exception.
Steps to Reproduce
- Create a topic that has 1 read queue and 1 write queue.
- Send 10 messages into the topic.
- Read the messages, for the 5th message, change its invisible duration and acknowledge it.
- Read the topic again, with the same consumer group.
What Did You Expect to See?
The acknowledged message would not be seen in the second read.
What Did You See Instead?
The acknowledged message was seen in the second read.
Additional Context
Test case:
Found an old thread about the similar issue:
https://github.com/apache/rocketmq/discussions/6818
From cserwen's words, changeInvisibleDuration is not used for extending invisible duration. But I confirmed this view with Aliyun RocketMQ team, they are very sure that changeInvisibleDuration should be used for extending invisible duration.
when you change 5th message's invisible duration, rocketmq will do following things:
- ack the 5th msg,
- append a new ck message into timing wheel.
it means the old 5th message cant be acked after you change its invisible time.
when you change 5th message's invisible duration, rocketmq will do following things:
- ack the 5th msg,
- append a new ck message into timing wheel.
it means the old 5th message cant be acked after you change its invisible time.
Then what is the correct way to extend invisible duration for a long running task?
Background: we can't decide how long a task would take. One example is importing data from excel file. The process time is relevant to the number of rows in the file. We built an event-driven application based on RocketMQ. The background processes are driven by MQ messages. That why we need a way to extend invisible duration.
When the first pop operation is used to get messages, the server generates an initial handle A. If the visibility timeout is extended via the change invisiable time operation, the server creates a new handle B and triggers a state transition (effectively invalidating A and activating B). At this point, attempting to acknowledge the message using the old handle A will fail, as only the new handle B is valid for acknowledgment
When the first pop operation is used to get messages, the server generates an initial handle A. If the visibility timeout is extended via the change invisiable time operation, the server creates a new handle B and triggers a state transition (effectively invalidating A and activating B). At this point, attempting to acknowledge the message using the old handle A will fail, as only the new handle B is valid for acknowledgment
I understand. But please take a look at the source code, receiptHandle would be refreshed after changeInvisibleDuration. So in my case, I acknowledged to the new handle, not the old one.
https://github.com/apache/rocketmq-clients/blob/master/java/client/src/main/java/org/apache/rocketmq/client/java/impl/consumer/SimpleConsumerImpl.java#L288
Anyway, the point is not how it works, the point is what can we do.
My ask is:
- Confirm if it's a bug, and fix it.
- Or find a solution if it's not a bug.
This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.
This issue was closed because it has been inactive for 3 days since being marked as stale.