Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,15 @@ public boolean supportURLRepo() {
return supportURLRepo;
}

/**
* @return whether this repository performs overwrites atomically. In practice we only overwrite the `index.latest` blob so this
* is not very important, but the repository analyzer does test that overwrites happen atomically. It will skip those tests if the
* repository overrides this method to indicate that it does not support atomic overwrites.
*/
public boolean hasAtomicOverwrites() {
return true;
}

/**
* The result of removing a snapshot from a shard folder in the repository.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,11 @@ protected BlobStore createBlobStore() throws Exception {
protected ByteSizeValue chunkSize() {
return chunkSize;
}

@Override
public boolean hasAtomicOverwrites() {
// We overwrite a file by deleting the old file and then renaming the new file into place, which is not atomic.
// Also on Windows the overwrite may fail if the file is opened for reading at the time.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ private void validateLocalRepositorySecret(Map<String, Object> snapshotUserMetad
}
}

@Override
public boolean hasAtomicOverwrites() {
return delegatedRepository.hasAtomicOverwrites();
}

// pkg-private for tests
static final class EncryptedBlobStore implements BlobStore {
private final BlobStore delegatedBlobStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ private void onReadsComplete(Collection<NodeResponse> responses, WriteDetails wr
if (response.isNotFound()) {
if (request.readEarly) {
nodeFailure = null; // "not found" is legitimate iff we tried to read it before the write completed
} else if (request.writeAndOverwrite) {
nodeFailure = null; // overwrites surprisingly not necessarily atomic, e.g. in a FsBlobContainer
} else {
nodeFailure = new RepositoryVerificationException(
request.getRepositoryName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ public void run() {
request.getReadNodeCount(),
request.getEarlyReadNodeCount(),
smallBlob && random.nextDouble() < request.getRareActionProbability(),
repository.supportURLRepo() && smallBlob && random.nextDouble() < request.getRareActionProbability()
repository.supportURLRepo()
&& repository.hasAtomicOverwrites()
&& smallBlob
&& random.nextDouble() < request.getRareActionProbability()
)
);
queue.add(verifyBlobTask);
Expand Down