diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java index aa2cb3542b6..95341f9caea 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java @@ -108,15 +108,19 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { } public CommitPoint findCommitPoint(String index, int shardId) throws IOException { - ImmutableBlobContainer container = blobStore.immutableBlobContainer(BlobStoreIndexGateway.shardPath(basePath, index, shardId)); + BlobPath path = BlobStoreIndexGateway.shardPath(basePath, index, shardId); + ImmutableBlobContainer container = blobStore.immutableBlobContainer(path); ImmutableMap blobs = container.listBlobs(); List commitPointsList = Lists.newArrayList(); - for (String name : blobs.keySet()) { - if (name.startsWith("commit-")) { + for (BlobMetaData md : blobs.values()) { + if (md.length() == 0) { // a commit point that was not flushed yet... + continue; + } + if (md.name().startsWith("commit-")) { try { - commitPointsList.add(CommitPoints.fromXContent(container.readBlobFully(name))); + commitPointsList.add(CommitPoints.fromXContent(container.readBlobFully(md.name()))); } catch (Exception e) { - logger.warn("failed to read commit point [{}]", e, name); + logger.warn("failed to read commit point at path {} with name [{}]", e, path, md.name()); } } }