Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
It may happen that between retrieving files from remote and evaluating size of file, the remote file may get get removed leading to IO exception. Adding a check to handle this case.
IndexSanityChecker private boolean isThereASizeMismatch() throws IOException { for (String fileName : remote.listAll()){ long localLength = DirectoryUtils.getFileLength(local, fileName); long remoteLength = remote.fileLength(fileName); // <== line 81 //This is a weak check based on length. if (localLength > 0 && localLength != remoteLength){ log.warn("[{}] Found local copy for {} in {} but size of local {} differs from remote {}. ", indexPath, fileName, local, localLength, remoteLength); return true; } if (localLength > 0) { localDirSize += localLength; localFileCount++; } remoteDirSize += remoteLength; remoteFileCount++; } return false; } OakDirectory: @Override public long fileLength(String name) throws IOException { NodeBuilder file = directoryBuilder.getChildNode(name); if (!file.exists()) { String msg = String.format("[%s] %s", indexName, name); throw new FileNotFoundException(msg); } OakIndexInput input = new OakIndexInput(name, file, indexName, blobFactory); try { return input.length(); } finally { input.close(); } }