Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1137

FilesystemStorageStrategyImpl throws NoSuchFileException when listing files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9.2
    • 2.0.0
    • jclouds-core

    Description

      When listing files in a local blobstore, we are sometimes hitting the following exception:

      java.nio.file.NoSuchFileException: /opt/data/./ggg/fff_local_db.db-wal
              at com.google.common.base.Throwables.propagate(Throwables.java:160)
              at org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl.getBlob(FilesystemStorageStrategyImpl.java:373)
              at org.jclouds.blobstore.config.LocalBlobStore.loadBlob(LocalBlobStore.java:414)
      ...
      Caused by: java.nio.file.NoSuchFileException: /opt/data/./ggg/fff_local_db.db-wal
              at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
              at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
              at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
              at sun.nio.fs.UnixPath.openForAttributeAccess(UnixPath.java:787)
              at sun.nio.fs.LinuxUserDefinedFileAttributeView.list(LinuxUserDefinedFileAttributeView.java:100)
              at org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl.getBlob(FilesystemStorageStrategyImpl.java:333)
      

      There is some kind of race condition when a file is being removed in the middle of a getBlob: to reproduce, one can put a breakpoint in FilesystemStorageStrategyImpl before the call to UserDefinedFileAttributeView.list, and remove the current file from the file system when hitting the breakpoint.

      The workaround we are using is to provide our own version of FilesystemStorageStrategyImpl that patches the getBlob method in this fashion:

          @Override
          public Blob getBlob(String container, String key) {
              try {
                  return super.getBlob(container, key);
              } catch (RuntimeException t) {
                  if (t.getCause() instanceof NoSuchFileException) {
                      log.warn("file `" + key + "' has been removed during the getBlob", t);
                      return newBlob("deleted." + key + "." + System.currentTimeMillis());
                  } else {
                      throw t;
                  }
              }
          }
      

      This ensures a blob is returned. Returning null is not enough as LocalBlobStore.list would thrown an exception "blob is not present although it was in the list of container".

      Attachments

        Activity

          People

            gaul Andrew Gaul
            frigo Francois Rigault
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: