Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-2855

CopyOnReadDirectory mode might delete a valid local file upon close




      CopyOnReadDirectory currently deletes local files which are not found in remote upon close. The list of remote file is fixed for a given revision however list of local files may vary.

      IndexTracker opens a new IndexNode upon update before closing the older one. When CopyOnRead is enabled it can happen that same local directory might be in use by two wrapper directories at the same time.

      This introduces a race condition in removeDeletedFiles method as by the time it is invoked a newer wrapped directory might have started adding new files so those files would get included in the listing done for local directory and hence cause them to be deleted as they would not be found in remote directory which is pinned to older revision. Leading to following exception

      Caused by: java.io.FileNotFoundException: /path/to/crx-quickstart/repository/index/e5a943cdec3000bd8ce54924fd2070ab5d1d35b9ecf530963a3583d43bf28293/4/_1r.cfe (No such file or directory)
      	at java.io.RandomAccessFile.open(Native Method)
      	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)
      	at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:193)
      	at org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory$FileReference.openLocalInput(IndexCopier.java:393)
      	at org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier$CopyOnReadDirectory.openInput(IndexCopier.java:221)
      	at org.apache.lucene.store.Directory.copy(Directory.java:185)
      	at org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexMBeanImpl.dumpIndexContent(LuceneIndexMBeanImpl.java:104)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      As a fix the list of local file should be maintained as progress is made once the CopyOnRead instance gets created to ensure it does not pick up files which are added once the directory is closed


        Issue Links



              chetanm Chetan Mehrotra
              chetanm Chetan Mehrotra
              0 Vote for this issue
              1 Start watching this issue