You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/09/23 03:35:30 UTC

[GitHub] [rocketmq] frankcrc opened a new issue, #5174: index timeDiff precision missing may cause resend failed

frankcrc opened a new issue, #5174:
URL: https://github.com/apache/rocketmq/issues/5174

   **BUG REPORT**
   
   1. Please describe the issue you observed:
   
   If the time of machine which deployed broker is behind that of client, more precisely if the time in index is less than `BornTimestamp` minus 1000, resending message through dashboard or mqadmin may get "org.apache.rocketmq.client.exception.MQClientException: CODE: 208 DESC: query message by key finished, but no message" error.
   
   I read source code, and found `consumeMessageDirectly` method would first call `viewMessage` method. In `viewMessage`, it extracts `BornTimestamp` from `UniqueKey`, and then use this timestamp, which is in fact `BornTimestamp` minus 1000 ms, to request broker.
   
   Broker then gets message offset by index, and compares the time from request and the time in index.
   
   I think there is a problem. The time in index is constructed by `indexHeader.beginTimestamp` and `timeDiff`,and `timeDiff` is calculated using `StoreTimestamp`, you can see it at `org.apache.rocketmq.store.index.IndexFile#putKey`. StoreTimestamp's unit is millisecond and `timeDiff`'s unit is second, which means time in index could discard up to 999 ms.
   
   Using the following config and data should reproduce the problem.
   
   The following is broker's config,
   
   ``` config
   brokerClusterName=testLocal
   brokerName=broker-a
   brokerId=0
   deleteWhen=04
   fileReservedTime=72
   brokerRole=SYNC_MASTER
   flushDiskType=SYNC_FLUSH
   
   namesrvAddr=127.0.0.1:9876
   brokerIP1=127.0.0.1
   brokerIP2=127.0.0.1
   
   storePathRootDir=/path/to/broker-a-m
   storePathCommitLog=/path/to/broker-a-m/commitlog
   
   mappedFileSizeCommitLog=1024*1024*1024
   
   waitTimeMillsInSendQueue=5000
   ```
   
   The following is broker-a-m's data,
   https://github.com/frankcrc/issue-attachment/blob/main/broker-a-m.tar.gz
   
   Run a consumer, which subscribes TopicTest Topic, and uses mdw-test-consume-group as its name.
   
   Run a dashboard, and setup namesrv addr, and open Message tab, and search message in TopicTest Topic between 2022-09-21 07:00 and 2022-09-22 07:00.
   
   Then you can see 3 messages.
   You can check `0AD0341A4F4418B4AAC26A30F3090000` detail, and click `RESEND MESSAGE`, and you should get "no messsage" error.
   You can check `0AD0341A4F0818B4AAC26A3314410000` detail, and click `RESEND MESSAGE`, and you should reconsume success.
   
   I think it should always success as long as i could get the message details, but it does not.
   
   2. Please tell us about your environment:
   
   System: UOS 
   RocketMQ version: v4.5.2
   RocketMQ dashboard: 1.0.0
   RocketMQ version of consumer client: v4.6.0
   
   3. Other information (e.g. detailed explanation, logs, related issues, suggestions on how to fix, etc):
   
   
   


-- 
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: dev-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ShadowySpirits commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
ShadowySpirits commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1260565111

   > If client can specify timestamp, that's ok. But all the timestamps used in consumeMessageDirectly are calculated inner, client cannot control unless implements a special MqAdminExt.
   
   Sorry, I don't get your point. The consumeMessageDirectly will call viewMessage method and decode broker IP and message phyOffset. And then, use this IP and offset to fetch message from broker. I find nothing about the born timestamp in this process.
   
   > From the code, this problem could reproduce as long as the storeTimestamp less than bornTimestamp, even if storeTimestamp were just 1ms behind.
   
   There is a simple way to alleviate this problem. Each born timestamp using in mqadmin minus a fixed time by default, such as 3s.


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] index timeDiff precision missing may cause resend failed [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1760561179

   This issue was closed because it has been inactive for 3 days since being marked as stale.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] index timeDiff precision missing may cause resend failed [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #5174: index timeDiff precision missing may cause resend failed
URL: https://github.com/apache/rocketmq/issues/5174


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] index timeDiff precision missing may cause resend failed [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1754088074

   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 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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ni-ze commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
ni-ze commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1257405100

   If the clock in client and broker is synchronous, I think this error would not occur.


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] frankcrc commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
frankcrc commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1260402596

   Thanks for reply, @ni-ze @ShadowySpirits .
   
   From the code, this problem could reproduce as long as the `storeTimestamp` less than `bornTimestamp`, even if `storeTimestamp` were just 1ms behind.
   
   I wanna know if there a recommanded time difference threshold between client and broker. Let say 20ms, if the time difference were larger than this, this problem would be more likely to happen.
   
   > IMO, this is not a bug. Most APIs in the broker, such as SEARCH_OFFSET_BY_TIMESTAMP, and QUERY_MESSAGE, use store timestamp, not born timestamp. Because multiple clients are more likely has clock synchronization problems.
   
   If client can specify timestamp, that's ok. But all the timestamps used in `consumeMessageDirectly` are calculated inner, client cannot control unless implements a special `MqAdminExt`.
   
   So I think , maybe, we could modify 'consumeMessageDirectly',  add a optional timestamp parameter to it.


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] frankcrc commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
frankcrc commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1260491326

   > From the code, this problem could reproduce as long as the `storeTimestamp` less than `bornTimestamp`, even if `storeTimestamp` were just 1ms behind.
   
   Sorry, it should be 2ms.
   
   In `org.apache.rocketmq.store.index.IndexFile#selectPhyOffset`, `timeRead` is in [`storeTimestamp` - 999, `storeTimestamp`], begin is `bornTimestamp` minus 1000. To resend success, `timeRead` needs to be larger or equal than begin. So
   
   ```
   timeRead >= begin
   
   =>
   
   storeTimestamp -999 >= bornTimestamp - 1000
   
   =>
   
   1 >= bornTimestamp - storeTimestamp
   ```


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ShadowySpirits commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
ShadowySpirits commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1259053893

   IMO, this is not a bug. Most APIs in the broker, such as SEARCH_OFFSET_BY_TIMESTAMP, and QUERY_MESSAGE, use store timestamp, not born timestamp. Because multiple clients are more likely has clock synchronization problems.


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] frankcrc commented on issue #5174: index timeDiff precision missing may cause resend failed

Posted by GitBox <gi...@apache.org>.
frankcrc commented on issue #5174:
URL: https://github.com/apache/rocketmq/issues/5174#issuecomment-1272426200

   Sorry, I confused timestamp in `UNIQ_KEY` with `bornTimestamp`. 
   
   In my environment, mq's version of broker and client are differnect. so `viewMessage` might encounter exception, I means `org.apache.rocketmq.common.message.MessageDecoder#decodeMessageId`.  This commit may be related, [c7c9601d](https://github.com/apache/rocketmq/commit/c7c9601d36d0179ae69592e541764b04130cf790#diff-da0b74e72334fbe4c8f96d48e86981af939efb20fb76554f93ae6eb9a38982b7L60-L64).
   
   Then,
   1.`org.apache.rocketmq.client.impl.MQAdminImpl#viewMessage` will throw "query message by id finished, but no message" exception, or
   2.`org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl#viewMessage(java.lang.String, java.lang.String)` will call `queryMessageByUniqKey`. In `queryMessageByUniqKey`, you can see 
   ```
   // which is begin
   // my misunderstood bornTimestamp - 1000
   MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000
   ```


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org