From 0ac9912b89b57cce555331359abb18d01cdf94ca Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 6 Nov 2014 23:18:33 +0100 Subject: [PATCH] [STORE] increment store in NoneIndexShardGateway and either check if dir is null or different but not both --- .../index/gateway/none/NoneIndexShardGateway.java | 3 +++ .../org/elasticsearch/index/store/DistributorDirectory.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java index de38668ebe8..bdf8238312b 100644 --- a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java @@ -63,11 +63,14 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement recoveryState.getIndex().startTime(System.currentTimeMillis()); // in the none case, we simply start the shard // clean the store, there should be nothing there... + indexShard.store().incRef(); try { logger.debug("cleaning shard content before creation"); indexShard.store().deleteContent(); } catch (IOException e) { logger.warn("failed to clean store before starting shard", e); + } finally { + indexShard.store().decRef(); } indexShard.postRecovery("post recovery from gateway"); recoveryState.getIndex().time(System.currentTimeMillis() - recoveryState.getIndex().startTime()); diff --git a/src/main/java/org/elasticsearch/index/store/DistributorDirectory.java b/src/main/java/org/elasticsearch/index/store/DistributorDirectory.java index 10f397fe0fe..84a88422c8d 100644 --- a/src/main/java/org/elasticsearch/index/store/DistributorDirectory.java +++ b/src/main/java/org/elasticsearch/index/store/DistributorDirectory.java @@ -203,8 +203,7 @@ public final class DistributorDirectory extends BaseDirectory { builder.append("File ").append(file) .append(" was not mapped to a directory but exists in one of the distributors directories") .append(System.lineSeparator()); - } - if (directory != d) { + } else if (directory != d) { consistent = false; builder.append("File ").append(file).append(" was mapped to a directory ").append(directory) .append(" but exists in another distributor directory").append(d)