fluyu opened a new issue #331:
URL: https://github.com/apache/rocketmq-client-cpp/issues/331


   **BUG REPORT**
   
   1. Please describe the issue you observed:
   
   - What did you do (The steps to reproduce)?
   
   > nromal usage of orderly PusherConsumer
   
   - What did you expect to see?
   
   > messages should be consumed only once under normal conditions, i.e. no 
rebalance
   
   - What did you see instead?
   
   > the same mesage could be consumed multiple times in the user consumer 
callback
   
   2. Please tell us about your environment:
   
    - What is your OS?
   
   > CentOS 7
   
    - What is your client version?
   
   > ecfd7d3a5
   
    - What is your RocketMQ version?
   
   > 4.7
   
   3. Other information (e.g. detailed explanation, logs, related issues, 
suggestions on how to fix, etc):
   
   Actually this issue could be considered as a side effect of  #322 
   
   After the fix, when no new messages are found in the pull result while there 
is some message pending consumption completion inside the`m_msgTreeMapTemp`, 
the next pull offset should be set to the largest one in `m_msgTreeMapTemp`, 
not `pullResult.nextBeginOffset`.
   
   I suggest add a new function `PullRequest::setPossibleNextOffset` like the 
following:
   ```cpp
   void PullRequest::setPossibleNextOffset(int64 nextoffset) {
     boost::lock_guard<boost::mutex> lock(m_pullRequestLock);
     
     map<int64, MQMessageExt>::iterator it = m_msgTreeMap.begin();
     for (; it != m_msgTreeMap.end(); it++) {
       nextoffset = (std::max)(it->second.getQueueOffset() + 1, nextoffset);
     }
     it = m_msgTreeMapTemp.begin();
     for (; it != m_msgTreeMapTemp.end(); it++) {
       nextoffset = (std::max)(it->second.getQueueOffset() + 1, nextoffset);
     }
   
     m_nextOffset = nextoffset;
   }
   ```
   and use it at the following locations: 
   
[DefaultMQPushConsumerImpl.cpp#L97](https://github.com/apache/rocketmq-client-cpp/blob/ecfd7d3a598a54288817c038cb13f25c26bd370f/src/consumer/DefaultMQPushConsumerImpl.cpp#L97)
   
[DefaultMQPushConsumerImpl.cpp#L117](https://github.com/apache/rocketmq-client-cpp/blob/ecfd7d3a598a54288817c038cb13f25c26bd370f/src/consumer/DefaultMQPushConsumerImpl.cpp#L117)
   
[DefaultMQPushConsumerImpl.cpp#L738](https://github.com/apache/rocketmq-client-cpp/blob/ecfd7d3a598a54288817c038cb13f25c26bd370f/src/consumer/DefaultMQPushConsumerImpl.cpp#L738)
   
[DefaultMQPushConsumerImpl.cpp#L752](https://github.com/apache/rocketmq-client-cpp/blob/ecfd7d3a598a54288817c038cb13f25c26bd370f/src/consumer/DefaultMQPushConsumerImpl.cpp#L752)
   
   Is this change correct?
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to