Skip to content

Commit 8daa0f1

Browse files
Remove unnecessary sync from FsBlobStore (#95412)
This confused me while looking into something unrelated. There's no need to sync a createDirectories call like this, the file system does that for us. We do however in some cases create containers concurrently across many threads which visbly blocks here.
1 parent 2386a8c commit 8daa0f1

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobStore.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,22 @@ public int bufferSizeInBytes() {
5050

5151
@Override
5252
public BlobContainer blobContainer(BlobPath path) {
53-
try {
54-
return new FsBlobContainer(this, path, buildAndCreate(path));
55-
} catch (IOException ex) {
56-
throw new ElasticsearchException("failed to create blob container", ex);
53+
Path f = buildPath(path);
54+
if (readOnly == false) {
55+
try {
56+
Files.createDirectories(f);
57+
} catch (IOException ex) {
58+
throw new ElasticsearchException("failed to create blob container", ex);
59+
}
5760
}
61+
return new FsBlobContainer(this, path, f);
5862
}
5963

6064
@Override
6165
public void close() {
6266
// nothing to do here...
6367
}
6468

65-
private synchronized Path buildAndCreate(BlobPath path) throws IOException {
66-
Path f = buildPath(path);
67-
if (readOnly == false) {
68-
Files.createDirectories(f);
69-
}
70-
return f;
71-
}
72-
7369
private Path buildPath(BlobPath path) {
7470
List<String> paths = path.parts();
7571
if (paths.isEmpty()) {

0 commit comments

Comments
 (0)