iamqq23ue opened a new pull request, #4306:
URL: https://github.com/apache/rocketmq/pull/4306

   #2706  I found that the problem still exists in version 4.9.3
   when the flush is abnormal ,SEND_OK will still be returned 。It will cause 
possible message loss .
   
   error code show as below :
   
   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.
   
   
   `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.
                       this.flushError = false;
                       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();
       }`
   
   I recommend passing the error to the client


-- 
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: [email protected]

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

Reply via email to