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 2021/04/01 04:16:11 UTC

[GitHub] [rocketmq] iamqq23ue edited a comment on issue #2706: SEND_OK will still be returned when the storage is abnormal ,which may cause message loss

iamqq23ue edited a comment on issue #2706:
URL: https://github.com/apache/rocketmq/issues/2706#issuecomment-806547913


   Start RocketMQ first, then set the file system to read only。file system!Not a  file。
   
   
   
   
   ------------------&nbsp;原始邮件&nbsp;------------------
   发件人:                                                                                                                        "apache/rocketmq"                                                                                    ***@***.***&gt;;
   发送时间:&nbsp;2021年3月25日(星期四) 下午5:10
   ***@***.***&gt;;
   ***@***.******@***.***&gt;;
   主题:&nbsp;Re: [apache/rocketmq] SEND_OK will still be returned when the storage is abnormal  ,which may cause message loss (#2706)
   
   
   
   
   
         
   when the flush is abnormal ,SEND_OK will still be returned 。It will cause possible message loss .
    I will submit a PR to fix it
    code show as below :
    public int flush(final int flushLeastPages) {     if (this.isAbleToFlush(flushLeastPages)) {         if (this.hold()) {             int value = getReadPosition();             try {                 //We only append data to fileChannel or mappedByteBuffer, never both.                 if (writeBuffer != null || this.fileChannel.position() != 0) {                     this.fileChannel.force(false);                 } else {                     this.mappedByteBuffer.force();                 }             } catch (Throwable e) {                 log.error("Error occurred when force data to disk.", e);             }             this.flushedPosition.set(value);             this.release();         } else {             log.warn("in flush, hold failed, flush offset = " + this.flushedPosition.get());             this.flushedPosition.set(getReadPosition());         }     }     return this.getFlushedPosition(); }
     
   Can u details the situation, such as rmq version, and replicas setting?
     
   You can see that if there is an error, a try catch will be performed .Then log.error("Error occurred when force data to disk.", e);
    But there is no error code returned to the client, and the client still thinks that the send is successful.
     
   org.apache.rocketmq.store.CommitLog.GroupCommitService#doCommit
    You can see this method,if flush failed,the flushedWhere offset will not change。Then the value of PutMessageStatus will be FLUSH_DISK_TIMEOUT
     
   I do not think so.
    First of all, I can reproduce the problem. If the flush fails, it will still return SEND_OK. And after modifying the code, the problem is solved.So there must be a problem
    
   From the code analysis, even if the flush fails, docommit does not know. this.flushedPosition.set(value) will be executed no matter what。
    
   You can try to make the file system read-only, and then you can reproduce the problem
     
   测试过,如果在运行过程中,将文件改为只读,是可以强刷的。启动前改为只读,会报异常。您是怎么测试的呀
    
   —
   You are receiving this because you authored the thread.
   Reply to this email directly, view it on GitHub, or unsubscribe.


-- 
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:
users@infra.apache.org