-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Allow freezing searchable snapshots #52653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2ca67a8
2774b7f
206856a
8e0a73a
3f0cca1
9e3d4bf
b10dd74
bc85c25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; | ||
| import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; | ||
| import org.elasticsearch.action.index.IndexRequestBuilder; | ||
| import org.elasticsearch.action.support.IndicesOptions; | ||
| import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
| import org.elasticsearch.cluster.node.DiscoveryNode; | ||
| import org.elasticsearch.common.Priority; | ||
|
|
@@ -21,14 +22,17 @@ | |
| import org.elasticsearch.index.IndexSettings; | ||
| import org.elasticsearch.indices.recovery.RecoveryState; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.protocol.xpack.frozen.FreezeRequest; | ||
| import org.elasticsearch.snapshots.SnapshotInfo; | ||
| import org.elasticsearch.test.ESIntegTestCase; | ||
| import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction; | ||
| import org.elasticsearch.xpack.frozen.FrozenIndices; | ||
|
||
| import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.concurrent.CountDownLatch; | ||
|
|
@@ -50,7 +54,7 @@ protected boolean addMockInternalEngine() { | |
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return Collections.singletonList(SearchableSnapshots.class); | ||
| return Arrays.asList(SearchableSnapshots.class, FrozenIndices.class); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -139,6 +143,15 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception { | |
|
|
||
| assertRecovered(restoredIndexName, originalAllHits, originalBarHits); | ||
|
|
||
| if (randomBoolean()) { | ||
| assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest(restoredIndexName)).actionGet()); | ||
| ensureGreen(restoredIndexName); | ||
|
|
||
| // ensure that the index really was frozen by searching it without ignore_throttled=false and checking that it returns nothing | ||
| final TotalHits totalHits = client().prepareSearch(restoredIndexName).setTrackTotalHits(true).get().getHits().getTotalHits(); | ||
| assertThat(totalHits, equalTo(new TotalHits(0L, TotalHits.Relation.EQUAL_TO))); | ||
| } | ||
|
|
||
| internalCluster().fullRestart(); | ||
| assertRecovered(restoredIndexName, originalAllHits, originalBarHits); | ||
|
|
||
|
|
@@ -173,8 +186,10 @@ private void assertRecovered(String indexName, TotalHits originalAllHits, TotalH | |
| throw new RuntimeException(e); | ||
| } | ||
| allHits.set(t, client().prepareSearch(indexName).setTrackTotalHits(true) | ||
| .setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED) | ||
| .get().getHits().getTotalHits()); | ||
| barHits.set(t, client().prepareSearch(indexName).setTrackTotalHits(true) | ||
| .setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED) | ||
| .setQuery(matchQuery("foo", "bar")).get().getHits().getTotalHits()); | ||
| }); | ||
| threads[i].start(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about introducing this string literal here, vs adding a dependency on the
frozen-indicesmodule and referring to the setting directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to avoid the dependency and just use the String literal (we have other such cases in our code base).
I also wonder if we need to handle closed replicated snapshot indices (i.e. use
NoOpEnginefor those).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already bypass this mechanism for closed indices:
elasticsearch/server/src/main/java/org/elasticsearch/indices/IndicesService.java
Lines 622 to 627 in 0d1e67d
I added a test case showing that closing and reopening a searchable snapshot index does work.