From cf986727f283d2a343137a8dd9f9e0b5276ef5e0 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Tue, 24 Sep 2019 14:29:22 -0400 Subject: [PATCH] Remove ensureIndexHasHistoryUUID --- .../org/elasticsearch/index/store/Store.java | 16 ---------- .../elasticsearch/index/store/StoreTests.java | 32 ------------------- 2 files changed, 48 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/store/Store.java b/server/src/main/java/org/elasticsearch/index/store/Store.java index eae9ca3a8bda6..e84d8b9586f15 100644 --- a/server/src/main/java/org/elasticsearch/index/store/Store.java +++ b/server/src/main/java/org/elasticsearch/index/store/Store.java @@ -1484,22 +1484,6 @@ public void associateIndexWithNewTranslog(final String translogUUID) throws IOEx } } - - /** - * Checks that the Lucene index contains a history uuid marker. If not, a new one is generated and committed. - */ - public void ensureIndexHasHistoryUUID() throws IOException { - metadataLock.writeLock().lock(); - try (IndexWriter writer = newAppendingIndexWriter(directory, null)) { - final Map userData = getUserData(writer); - if (userData.containsKey(Engine.HISTORY_UUID_KEY) == false) { - updateCommitData(writer, Collections.singletonMap(Engine.HISTORY_UUID_KEY, UUIDs.randomBase64UUID())); - } - } finally { - metadataLock.writeLock().unlock(); - } - } - /** * Keeping existing unsafe commits when opening an engine can be problematic because these commits are not safe * at the recovering time but they can suddenly become safe in the future. diff --git a/server/src/test/java/org/elasticsearch/index/store/StoreTests.java b/server/src/test/java/org/elasticsearch/index/store/StoreTests.java index 88da2b349f71e..c37a1d90b84da 100644 --- a/server/src/test/java/org/elasticsearch/index/store/StoreTests.java +++ b/server/src/test/java/org/elasticsearch/index/store/StoreTests.java @@ -1029,38 +1029,6 @@ public void testCanReadOldCorruptionMarker() throws IOException { store.close(); } - public void testEnsureIndexHasHistoryUUID() throws IOException { - final ShardId shardId = new ShardId("index", "_na_", 1); - try (Store store = new Store(shardId, INDEX_SETTINGS, StoreTests.newDirectory(random()), new DummyShardLock(shardId))) { - - store.createEmpty(Version.LATEST); - - // remove the history uuid - IndexWriterConfig iwc = new IndexWriterConfig(null) - .setCommitOnClose(false) - // we don't want merges to happen here - we call maybe merge on the engine - // later once we stared it up otherwise we would need to wait for it here - // we also don't specify a codec here and merges should use the engines for this index - .setMergePolicy(NoMergePolicy.INSTANCE) - .setOpenMode(IndexWriterConfig.OpenMode.APPEND); - try (IndexWriter writer = new IndexWriter(store.directory(), iwc)) { - Map newCommitData = new HashMap<>(); - for (Map.Entry entry : writer.getLiveCommitData()) { - if (entry.getKey().equals(Engine.HISTORY_UUID_KEY) == false) { - newCommitData.put(entry.getKey(), entry.getValue()); - } - } - writer.setLiveCommitData(newCommitData.entrySet()); - writer.commit(); - } - - store.ensureIndexHasHistoryUUID(); - - SegmentInfos segmentInfos = Lucene.readSegmentInfos(store.directory()); - assertThat(segmentInfos.getUserData(), hasKey(Engine.HISTORY_UUID_KEY)); - } - } - public void testHistoryUUIDCanBeForced() throws IOException { final ShardId shardId = new ShardId("index", "_na_", 1); try (Store store = new Store(shardId, INDEX_SETTINGS, StoreTests.newDirectory(random()), new DummyShardLock(shardId))) {