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 2018/01/17 12:37:36 UTC

[GitHub] Jason918 commented on a change in pull request #220: [ROCKETMQ-332] MappedFileQueue#findMappedFileByOffset is not thread safe, which will cause message loss.

Jason918 commented on a change in pull request #220: [ROCKETMQ-332] MappedFileQueue#findMappedFileByOffset is not thread safe, which will cause message loss.
URL: https://github.com/apache/rocketmq/pull/220#discussion_r162038566
 
 

 ##########
 File path: store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
 ##########
 @@ -461,26 +461,38 @@ public boolean commit(final int commitLeastPages) {
      */
     public MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound) {
         try {
-            MappedFile mappedFile = this.getFirstMappedFile();
-            if (mappedFile != null) {
-                int index = (int) ((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
+            MappedFile firstMappedFile = this.getFirstMappedFile();
 
 Review comment:
    If the first mappedFile is deleted between line 464 and line 467, this method still returns null when the requested offset is in the last mappedFile( mappedFiles.size() is less than index).
   @zhouxinyu @dongeforever 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services