From 4aaec5742f501d64537c0a8f7380aeb24876040e Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Thu, 19 Jul 2018 19:26:53 +0200 Subject: [PATCH 1/6] Fail shard if IndexShard#storeStats runs into an IOException --- .../elasticsearch/index/shard/IndexShard.java | 7 ++ .../index/shard/IndexShardTests.java | 88 ++++++++++++++++++- .../BlobStoreRepositoryRestoreTests.java | 2 +- .../ESIndexLevelReplicationTestCase.java | 2 +- .../index/shard/IndexShardTestCase.java | 37 +++++--- 5 files changed, 117 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index fc08438a7d9c5..1237412b85ea1 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -917,6 +917,13 @@ public StoreStats storeStats() { try { return store.stats(); } catch (IOException e) { + failShard("Failing shard because of exception during storeState " + e.getMessage(), e); + //TODO should close method be called inside failShard? + try { + close("Closing shard because of exception during storeStats " + e.getMessage(), false); + } catch (IOException e1) { + logger.warn("Error closing shard"); + } throw new ElasticsearchException("io exception while building 'store stats'", e); } } diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 15e6151457fa2..833a84c243140 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -27,6 +27,8 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.AlreadyClosedException; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.Constants; import org.elasticsearch.Version; @@ -112,6 +114,7 @@ import org.elasticsearch.test.FieldMaskingReader; import org.elasticsearch.test.VersionUtils; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.ElasticsearchException; import java.io.IOException; import java.nio.charset.Charset; @@ -138,6 +141,7 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.LongFunction; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -1162,6 +1166,83 @@ public void testShardStats() throws IOException { closeShards(shard); } + + public void testShardStatsWithFailures() throws IOException { + allowShardFailures(); + final ShardId shardId = new ShardId("index", "_na_", 0); + final ShardRouting shardRouting = newShardRouting(shardId, "node", true, RecoverySource.StoreRecoverySource.EMPTY_STORE_INSTANCE, ShardRoutingState.INITIALIZING); + final NodeEnvironment.NodePath nodePath = new NodeEnvironment.NodePath(createTempDir()); + + + ShardPath shardPath = new ShardPath(false, nodePath.resolve(shardId), nodePath.resolve(shardId), shardId); + Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) + .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) + .build(); + IndexMetaData metaData = IndexMetaData.builder(shardRouting.getIndexName()) + .settings(settings) + .primaryTerm(0, 1) + .build(); + + // Override one Directory methods to make it fail at our will + // We use AtomicReference here to inject failure in the middle of the test not immediately + // We use Supplier instead of IOException to produce meaningful stacktrace + // (remember stack trace is filled when exception is instantiated) + AtomicReference> exceptionToThrow = new AtomicReference<>(); + AtomicBoolean throwWhenMarkingStoreCorrupted = new AtomicBoolean(false); + Directory directory = new FilterDirectory(newFSDirectory(shardPath.resolveIndex())) { + //fileLength method is called during storeStats try block + //it's not called when store is marked as corrupted + @Override + public long fileLength(String name) throws IOException { + Supplier ex = exceptionToThrow.get(); + if (ex == null) { + return super.fileLength(name); + } else { + throw ex.get(); + } + } + + //listAll method is called when marking store as corrupted + @Override + public String[] listAll() throws IOException { + Supplier ex = exceptionToThrow.get(); + if (throwWhenMarkingStoreCorrupted.get() && ex != null) { + throw ex.get(); + } else { + return super.listAll(); + } + } + }; + + Store store = createStore(shardId, new IndexSettings(metaData, Settings.EMPTY), directory); + IndexShard shard = newShard(shardRouting, shardPath, metaData, store, + null, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); + + recoverShardFromStore(shard); + boolean corruptIndexException = true; + + if (randomBoolean()) { + exceptionToThrow.set(() -> new CorruptIndexException("Test CorruptIndexException", "Test resource")); + throwWhenMarkingStoreCorrupted.set(randomBoolean()); + } else { + corruptIndexException = false; + exceptionToThrow.set(() -> new IOException("Test IOException")); + } + ElasticsearchException e = expectThrows(ElasticsearchException.class, shard::storeStats); + assertThat(shard.state(), equalTo(IndexShardState.CLOSED)); + if (corruptIndexException && !throwWhenMarkingStoreCorrupted.get()) { + assertTrue(store.isMarkedCorrupted()); + } + + //TODO Should it be invoked when closing the shard? + try { + directory.close(); + } catch (IOException expected){ + //expected + } + } + public void testRefreshMetric() throws IOException { IndexShard shard = newStartedShard(); assertThat(shard.refreshStats().getTotal(), equalTo(2L)); // refresh on: finalize and end of recovery @@ -1868,6 +1949,7 @@ public IndexSearcher wrap(IndexSearcher searcher) throws EngineException { ShardRoutingHelper.initWithSameId(shard.routingEntry(), RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE), shard.shardPath(), shard.indexSettings().getIndexMetaData(), + null, wrapper, new InternalEngineFactory(), () -> {}, @@ -2020,7 +2102,7 @@ public IndexSearcher wrap(IndexSearcher searcher) throws EngineException { ShardRoutingHelper.initWithSameId(shard.routingEntry(), RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE), shard.shardPath(), shard.indexSettings().getIndexMetaData(), - wrapper, + null, wrapper, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); @@ -2506,7 +2588,7 @@ public void testReadSnapshotAndCheckIndexConcurrently() throws Exception { .put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), randomFrom("false", "true", "checksum", "fix"))) .build(); final IndexShard newShard = newShard(shardRouting, indexShard.shardPath(), indexMetaData, - null, indexShard.engineFactory, indexShard.getGlobalCheckpointSyncer(), EMPTY_EVENT_LISTENER); + null, null, indexShard.engineFactory, indexShard.getGlobalCheckpointSyncer(), EMPTY_EVENT_LISTENER); Store.MetadataSnapshot storeFileMetaDatas = newShard.snapshotStoreMetadata(); assertTrue("at least 2 files, commit and data: " + storeFileMetaDatas.toString(), storeFileMetaDatas.size() > 1); @@ -3005,7 +3087,7 @@ public void testFlushOnInactive() throws Exception { ShardPath shardPath = new ShardPath(false, nodePath.resolve(shardId), nodePath.resolve(shardId), shardId); AtomicBoolean markedInactive = new AtomicBoolean(); AtomicReference primaryRef = new AtomicReference<>(); - IndexShard primary = newShard(shardRouting, shardPath, metaData, null, new InternalEngineFactory(), () -> { + IndexShard primary = newShard(shardRouting, shardPath, metaData, null, null, new InternalEngineFactory(), () -> { }, new IndexEventListener() { @Override public void onShardInactive(IndexShard indexShard) { diff --git a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java index 0eae9a1420068..347b80d22925e 100644 --- a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java +++ b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java @@ -104,7 +104,7 @@ public void testRestoreSnapshotWithExistingFiles() throws IOException { shardRouting, shard.shardPath(), shard.indexSettings().getIndexMetaData(), - null, + null, null, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); diff --git a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index 5a5ee12065c9c..2056269394754 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -265,7 +265,7 @@ public synchronized IndexShard addReplicaWithExistingPath(final ShardPath shardP RecoverySource.PeerRecoverySource.INSTANCE); final IndexShard newReplica = - newShard(shardRouting, shardPath, indexMetaData, null, getEngineFactory(shardRouting), () -> {}, EMPTY_EVENT_LISTENER); + newShard(shardRouting, shardPath, indexMetaData, null, null, getEngineFactory(shardRouting), () -> {}, EMPTY_EVENT_LISTENER); replicas.add(newReplica); updateAllocationIDsOnPrimary(); return newReplica; diff --git a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java index 0cbc6e44502fe..bb2270e5357f8 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java @@ -163,15 +163,21 @@ public Settings threadPoolSettings() { return Settings.EMPTY; } - private Store createStore(IndexSettings indexSettings, ShardPath shardPath) throws IOException { - final ShardId shardId = shardPath.getShardId(); + + protected Store createStore(IndexSettings indexSettings, ShardPath shardPath) throws IOException { + return createStore(shardPath.getShardId(), indexSettings, newFSDirectory(shardPath.resolveIndex())); + } + + protected Store createStore(ShardId shardId, IndexSettings indexSettings, Directory directory) throws IOException { final DirectoryService directoryService = new DirectoryService(shardId, indexSettings) { @Override public Directory newDirectory() throws IOException { - return newFSDirectory(shardPath.resolveIndex()); + + return directory; } }; return new Store(shardId, indexSettings, directoryService, new DummyShardLock(shardId)); + } /** @@ -284,29 +290,32 @@ protected IndexShard newShard(ShardRouting routing, IndexMetaData indexMetaData, final ShardId shardId = routing.shardId(); final NodeEnvironment.NodePath nodePath = new NodeEnvironment.NodePath(createTempDir()); ShardPath shardPath = new ShardPath(false, nodePath.resolve(shardId), nodePath.resolve(shardId), shardId); - return newShard(routing, shardPath, indexMetaData, indexSearcherWrapper, engineFactory, globalCheckpointSyncer, + return newShard(routing, shardPath, indexMetaData, null, indexSearcherWrapper, engineFactory, globalCheckpointSyncer, EMPTY_EVENT_LISTENER, listeners); } /** * creates a new initializing shard. - * @param routing shard routing to use - * @param shardPath path to use for shard data - * @param indexMetaData indexMetaData for the shard, including any mapping - * @param indexSearcherWrapper an optional wrapper to be used during searchers - * @param globalCheckpointSyncer callback for syncing global checkpoints - * @param indexEventListener index even listener - * @param listeners an optional set of listeners to add to the shard + * @param routing shard routing to use + * @param shardPath path to use for shard data + * @param indexMetaData indexMetaData for the shard, including any mapping + * @param store an optional custom store to use. If null a default file based store will be created + * @param indexSearcherWrapper an optional wrapper to be used during searchers + * @param globalCheckpointSyncer callback for syncing global checkpoints + * @param indexEventListener index event listener + * @param listeners an optional set of listeners to add to the shard */ protected IndexShard newShard(ShardRouting routing, ShardPath shardPath, IndexMetaData indexMetaData, - @Nullable IndexSearcherWrapper indexSearcherWrapper, + @Nullable Store store, @Nullable IndexSearcherWrapper indexSearcherWrapper, @Nullable EngineFactory engineFactory, Runnable globalCheckpointSyncer, IndexEventListener indexEventListener, IndexingOperationListener... listeners) throws IOException { final Settings nodeSettings = Settings.builder().put("node.name", routing.currentNodeId()).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, nodeSettings); final IndexShard indexShard; - final Store store = createStore(indexSettings, shardPath); + if (store == null) { + store = createStore(indexSettings, shardPath); + } boolean success = false; try { IndexCache indexCache = new IndexCache(indexSettings, new DisabledQueryCache(indexSettings), null); @@ -356,7 +365,7 @@ protected IndexShard reinitShard(IndexShard current, ShardRouting routing, Index routing, current.shardPath(), current.indexSettings().getIndexMetaData(), - null, + null, null, current.engineFactory, current.getGlobalCheckpointSyncer(), EMPTY_EVENT_LISTENER, listeners); From 10b83f962f5d9f6b246febc7bcf01c13ca1e48ae Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Fri, 20 Jul 2018 20:43:46 +0200 Subject: [PATCH 2/6] Fix line length --- .../replication/ESIndexLevelReplicationTestCase.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index 2056269394754..2b1841c39ae52 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -259,13 +259,14 @@ assert shardRoutings().stream() public synchronized IndexShard addReplicaWithExistingPath(final ShardPath shardPath, final String nodeId) throws IOException { final ShardRouting shardRouting = TestShardRouting.newShardRouting( - shardId, - nodeId, - false, ShardRoutingState.INITIALIZING, - RecoverySource.PeerRecoverySource.INSTANCE); + shardId, + nodeId, + false, ShardRoutingState.INITIALIZING, + RecoverySource.PeerRecoverySource.INSTANCE); final IndexShard newReplica = - newShard(shardRouting, shardPath, indexMetaData, null, null, getEngineFactory(shardRouting), () -> {}, EMPTY_EVENT_LISTENER); + newShard(shardRouting, shardPath, indexMetaData, null, null, getEngineFactory(shardRouting), + () -> {}, EMPTY_EVENT_LISTENER); replicas.add(newReplica); updateAllocationIDsOnPrimary(); return newReplica; From 8e1cbaac1a00429d3a65091c9103d2d8a8547dda Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Sun, 22 Jul 2018 23:53:38 +0200 Subject: [PATCH 3/6] Fix some of code review issues --- .../java/org/elasticsearch/index/shard/IndexShardTests.java | 6 +++--- .../org/elasticsearch/index/shard/IndexShardTestCase.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 833a84c243140..816b85fddae63 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -1220,13 +1220,13 @@ public String[] listAll() throws IOException { null, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); recoverShardFromStore(shard); - boolean corruptIndexException = true; - if (randomBoolean()) { + final boolean corruptIndexException = randomBoolean(); + + if (corruptIndexException) { exceptionToThrow.set(() -> new CorruptIndexException("Test CorruptIndexException", "Test resource")); throwWhenMarkingStoreCorrupted.set(randomBoolean()); } else { - corruptIndexException = false; exceptionToThrow.set(() -> new IOException("Test IOException")); } ElasticsearchException e = expectThrows(ElasticsearchException.class, shard::storeStats); diff --git a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java index bb2270e5357f8..b343eb33cf23c 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java @@ -172,7 +172,6 @@ protected Store createStore(ShardId shardId, IndexSettings indexSettings, Direct final DirectoryService directoryService = new DirectoryService(shardId, indexSettings) { @Override public Directory newDirectory() throws IOException { - return directory; } }; @@ -296,7 +295,7 @@ protected IndexShard newShard(ShardRouting routing, IndexMetaData indexMetaData, /** * creates a new initializing shard. - * @param routing shard routing to use + * @param routing shard routing to use * @param shardPath path to use for shard data * @param indexMetaData indexMetaData for the shard, including any mapping * @param store an optional custom store to use. If null a default file based store will be created From 6a324382ff931100f5108dff93637905d89e8695 Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Mon, 23 Jul 2018 09:11:58 +0200 Subject: [PATCH 4/6] Fix other review issues --- .../elasticsearch/index/shard/IndexShard.java | 6 --- .../index/shard/IndexShardTests.java | 42 +++++++++---------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 1237412b85ea1..17caebaac49ad 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -918,12 +918,6 @@ public StoreStats storeStats() { return store.stats(); } catch (IOException e) { failShard("Failing shard because of exception during storeState " + e.getMessage(), e); - //TODO should close method be called inside failShard? - try { - close("Closing shard because of exception during storeStats " + e.getMessage(), false); - } catch (IOException e1) { - logger.warn("Error closing shard"); - } throw new ElasticsearchException("io exception while building 'store stats'", e); } } diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 816b85fddae63..e6ade0292e81a 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -1184,7 +1184,7 @@ public void testShardStatsWithFailures() throws IOException { .primaryTerm(0, 1) .build(); - // Override one Directory methods to make it fail at our will + // Override two Directory methods to make them fail at our will // We use AtomicReference here to inject failure in the middle of the test not immediately // We use Supplier instead of IOException to produce meaningful stacktrace // (remember stack trace is filled when exception is instantiated) @@ -1215,31 +1215,29 @@ public String[] listAll() throws IOException { } }; - Store store = createStore(shardId, new IndexSettings(metaData, Settings.EMPTY), directory); - IndexShard shard = newShard(shardRouting, shardPath, metaData, store, - null, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); + try (Store store = createStore(shardId, new IndexSettings(metaData, Settings.EMPTY), directory)) { + IndexShard shard = newShard(shardRouting, shardPath, metaData, store, + null, new InternalEngineFactory(), () -> { + }, EMPTY_EVENT_LISTENER); + AtomicBoolean failureCallbackTriggered = new AtomicBoolean(false); + shard.addShardFailureCallback((ig)->failureCallbackTriggered.set(true)); - recoverShardFromStore(shard); + recoverShardFromStore(shard); - final boolean corruptIndexException = randomBoolean(); + final boolean corruptIndexException = randomBoolean(); - if (corruptIndexException) { - exceptionToThrow.set(() -> new CorruptIndexException("Test CorruptIndexException", "Test resource")); - throwWhenMarkingStoreCorrupted.set(randomBoolean()); - } else { - exceptionToThrow.set(() -> new IOException("Test IOException")); - } - ElasticsearchException e = expectThrows(ElasticsearchException.class, shard::storeStats); - assertThat(shard.state(), equalTo(IndexShardState.CLOSED)); - if (corruptIndexException && !throwWhenMarkingStoreCorrupted.get()) { - assertTrue(store.isMarkedCorrupted()); - } + if (corruptIndexException) { + exceptionToThrow.set(() -> new CorruptIndexException("Test CorruptIndexException", "Test resource")); + throwWhenMarkingStoreCorrupted.set(randomBoolean()); + } else { + exceptionToThrow.set(() -> new IOException("Test IOException")); + } + ElasticsearchException e = expectThrows(ElasticsearchException.class, shard::storeStats); + assertTrue(failureCallbackTriggered.get()); - //TODO Should it be invoked when closing the shard? - try { - directory.close(); - } catch (IOException expected){ - //expected + if (corruptIndexException && !throwWhenMarkingStoreCorrupted.get()) { + assertTrue(store.isMarkedCorrupted()); + } } } From 25764620147e3b7412e0e9592c380583a2340761 Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Mon, 23 Jul 2018 15:14:50 +0200 Subject: [PATCH 5/6] Fix issues found by jasontedor --- .../main/java/org/elasticsearch/index/shard/IndexShard.java | 2 +- .../java/org/elasticsearch/index/shard/IndexShardTests.java | 3 ++- .../blobstore/BlobStoreRepositoryRestoreTests.java | 3 ++- .../java/org/elasticsearch/index/shard/IndexShardTestCase.java | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 17caebaac49ad..827ec0602f3c6 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -917,7 +917,7 @@ public StoreStats storeStats() { try { return store.stats(); } catch (IOException e) { - failShard("Failing shard because of exception during storeState " + e.getMessage(), e); + failShard("Failing shard because of exception during storeStats " + e.getMessage(), e); throw new ElasticsearchException("io exception while building 'store stats'", e); } } diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index e6ade0292e81a..1880b6b0954dc 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -2100,7 +2100,8 @@ public IndexSearcher wrap(IndexSearcher searcher) throws EngineException { ShardRoutingHelper.initWithSameId(shard.routingEntry(), RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE), shard.shardPath(), shard.indexSettings().getIndexMetaData(), - null, wrapper, + null, + wrapper, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); diff --git a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java index 347b80d22925e..fa7de2d629112 100644 --- a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java +++ b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java @@ -104,7 +104,8 @@ public void testRestoreSnapshotWithExistingFiles() throws IOException { shardRouting, shard.shardPath(), shard.indexSettings().getIndexMetaData(), - null, null, + null, + null, new InternalEngineFactory(), () -> {}, EMPTY_EVENT_LISTENER); diff --git a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java index b343eb33cf23c..f9289f658614c 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java @@ -364,7 +364,8 @@ protected IndexShard reinitShard(IndexShard current, ShardRouting routing, Index routing, current.shardPath(), current.indexSettings().getIndexMetaData(), - null, null, + null, + null, current.engineFactory, current.getGlobalCheckpointSyncer(), EMPTY_EVENT_LISTENER, listeners); From f76d9240bfba7dea98c46c5ffa9bb8b2dccc7a73 Mon Sep 17 00:00:00 2001 From: Andrey Ershov Date: Mon, 23 Jul 2018 15:23:58 +0200 Subject: [PATCH 6/6] Fix more issues found by jasontedor --- .../src/main/java/org/elasticsearch/index/shard/IndexShard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 827ec0602f3c6..d4a1d0502d0aa 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -917,7 +917,7 @@ public StoreStats storeStats() { try { return store.stats(); } catch (IOException e) { - failShard("Failing shard because of exception during storeStats " + e.getMessage(), e); + failShard("Failing shard because of exception during storeStats", e); throw new ElasticsearchException("io exception while building 'store stats'", e); } }