You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/03/22 16:09:56 UTC

[GitHub] ivankelly commented on a change in pull request #1284: Improve FileInfoBackingCache

ivankelly commented on a change in pull request #1284: Improve FileInfoBackingCache
URL: https://github.com/apache/bookkeeper/pull/1284#discussion_r176476938
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfoBackingCache.java
 ##########
 @@ -52,25 +63,29 @@ CachedFileInfo loadFileInfo(long ledgerId, byte[] masterKey) throws IOException
                 // have been able to get a reference to it here.
                 // The caller of loadFileInfo owns the refence, and is
                 // responsible for calling the corresponding #release().
-                boolean retained = fi.tryRetain();
-                assert(retained);
-                return fi;
+                return tryRetainFileInfo(fi);
             }
         } finally {
             lock.readLock().unlock();
         }
 
+        File backingFile = fileLoader.load(ledgerId, masterKey != null);
+        CachedFileInfo newFi = new CachedFileInfo(ledgerId, backingFile, masterKey);
 
 Review comment:
   I put the load inside the lock for a reason. This change introduces a race.
   
   ```
     | ThreadA                                | ThreadB                                |
     | ====================================== | ====================================== |
     | calls loadInfoInfo                     |                                        |
     | - checks fileInfos under read lock     |                                        |
     | - loads fileinfo for file              |                                        |
     |                                        | calls loadFileInfo                     |
     |                                        | - checks fileInfos under read lock     |
     |                                        | - loads fileinfo for file              |
     |                                        | - puts into fileInfos under write lock |
     |                                        |                                        |
     |                                        | // does something else, maybe fencing  |
     |                                        |                                        |
     |                                        | calls releaseFileInfo                  |
     |                                        | - flushes out fencing flag             |
     |                                        | - removes from fileInfo                |
     | - puts info fileInfos under write lock |                                        |
   ```
   

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