mbwaheed commented on a change in pull request #1055: SOLR-13932 Review directory locking and Blob interactions URL: https://github.com/apache/lucene-solr/pull/1055#discussion_r356424846
########## File path: solr/core/src/java/org/apache/solr/store/blob/metadata/SharedStoreResolutionUtil.java ########## @@ -147,42 +139,53 @@ public static SharedMetadataResolutionResult resolveMetadata(ServerSideMetadata if (local == null) { // The shard index data does not exist locally. All we can do is pull. - // We've computed blobFilesMissingLocally and localFilesMissingOnBlob is empty as it should be. + // We've computed blobFilesMissingLocally. localFilesMissingOnBlob is empty as it should be. return new SharedMetadataResolutionResult(localFilesMissingOnBlob.values(), blobFilesMissingLocally.values(), blobFilesMissingLocally.values(), false); } - boolean localConflictingWithBlob = false; + // If trying to pull files from Blob, make sure similarly named files do not already exist outside the current commit point + ImmutableSet<String> allLocalFiles = local.getAllFiles(); + + boolean downloadToNewDir = false; // Verify there are no inconsistencies between local index and blob index files for (BlobFile bf : distant.getBlobFiles()) { + final String solrFilename = bf.getSolrFileName(); // We remove from map of local files those already present remotely since they don't have to be pushed. - localFilesMissingOnBlob.remove(bf.getSolrFileName()); - CoreFileData cf = allLocalFiles.get(bf.getSolrFileName()); - if (cf != null) { + CoreFileData localFile = localFilesMissingOnBlob.remove(solrFilename); + if (localFile != null) { // The blob file is present locally. Check if there is a conflict between local and distant (blob) versions of that file. - blobFilesMissingLocally.remove(bf.getSolrFileName()); - if (cf.getFileSize() != bf.getFileSize() || cf.getChecksum() != bf.getChecksum()) { - String message = String.format("Size/Checksum conflicts sharedShardName=%s coreName=%s fileName=%s blobName=%s" + + blobFilesMissingLocally.remove(solrFilename); + if (localFile.getFileSize() != bf.getFileSize() || localFile.getChecksum() != bf.getChecksum()) { + String message = String.format("Size/Checksum conflicts. sharedShardName=%s coreName=%s fileName=%s blobName=%s" + " localSize=%s blobSize=%s localChecksum=%s blobCheckSum=%s", - distant.getSharedBlobName(), local.getCoreName(), bf.getSolrFileName(), bf.getBlobName(), - cf.getFileSize(), bf.getFileSize(), cf.getChecksum(), bf.getChecksum()); + distant.getSharedBlobName(), local.getCoreName(), solrFilename, bf.getBlobName(), + localFile.getFileSize(), bf.getFileSize(), localFile.getChecksum(), bf.getChecksum()); log.info(message); - localConflictingWithBlob = true; + downloadToNewDir = true; } + } else if (allLocalFiles.contains(solrFilename)) { + // If the file is NOT in current commit point but similar name file exists in local dir, we risk conflict. + log.info("File exists locally outside of commit point. sharedShardName=" + distant.getSharedBlobName() + " coreName="+ local.getCoreName() Review comment: outside of commit point -- > outside of current commit point ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org