Revert "Deprecate synced flush (#50835)"

This reverts commit 1a32d7142a.
This commit is contained in:
Nhat Nguyen 2020-01-13 11:40:47 -05:00
parent d1bde0a718
commit 05f97d5e1b
13 changed files with 73 additions and 79 deletions

View File

@ -601,10 +601,7 @@ public final class IndicesClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response * @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response * @throws IOException in case there is a problem sending the request or parsing back the response
* @deprecated synced flush is deprecated and will be removed in 8.0.
* Use {@link #flush(FlushRequest, RequestOptions)} instead.
*/ */
@Deprecated
public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException { public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options, return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,
SyncedFlushResponse::fromXContent, emptySet()); SyncedFlushResponse::fromXContent, emptySet());
@ -618,10 +615,7 @@ public final class IndicesClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion * @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request * @return cancellable that may be used to cancel the request
* @deprecated synced flush is deprecated and will be removed in 8.0.
* Use {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} instead.
*/ */
@Deprecated
public Cancellable flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options, public Cancellable flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options,
ActionListener<SyncedFlushResponse> listener) { ActionListener<SyncedFlushResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options, return restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,

View File

@ -100,7 +100,6 @@ import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.indices.flush.SyncedFlushService;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction; import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction; import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction;
@ -983,8 +982,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndex(index, settings); createIndex(index, settings);
SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(index); SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(index);
SyncedFlushResponse flushResponse = SyncedFlushResponse flushResponse =
execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync, execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync);
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE));
assertThat(flushResponse.totalShards(), equalTo(1)); assertThat(flushResponse.totalShards(), equalTo(1));
assertThat(flushResponse.successfulShards(), equalTo(1)); assertThat(flushResponse.successfulShards(), equalTo(1));
assertThat(flushResponse.failedShards(), equalTo(0)); assertThat(flushResponse.failedShards(), equalTo(0));
@ -999,8 +997,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
execute( execute(
syncedFlushRequest, syncedFlushRequest,
highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSynced,
highLevelClient().indices()::flushSyncedAsync, highLevelClient().indices()::flushSyncedAsync
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE)
) )
); );
assertEquals(RestStatus.NOT_FOUND, exception.status()); assertEquals(RestStatus.NOT_FOUND, exception.status());

View File

@ -839,8 +839,7 @@ public class RestHighLevelClientTests extends ESTestCase {
// looking like it doesn't have a valid implementatation when it does. // looking like it doesn't have a valid implementatation when it does.
apiUnsupported.remove("indices.get_template"); apiUnsupported.remove("indices.get_template");
// Synced flush is deprecated
apiUnsupported.remove("indices.flush_synced");
for (Map.Entry<String, Set<Method>> entry : methods.entrySet()) { for (Map.Entry<String, Set<Method>> entry : methods.entrySet()) {
String apiName = entry.getKey(); String apiName = entry.getKey();

View File

@ -1019,9 +1019,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// end::flush-synced-request-indicesOptions // end::flush-synced-request-indicesOptions
// tag::flush-synced-execute // tag::flush-synced-execute
SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request, expectWarnings( SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request, RequestOptions.DEFAULT);
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead."
));
// end::flush-synced-execute // end::flush-synced-execute
// tag::flush-synced-response // tag::flush-synced-response
@ -1065,9 +1063,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
listener = new LatchedActionListener<>(listener, latch); listener = new LatchedActionListener<>(listener, latch);
// tag::flush-synced-execute-async // tag::flush-synced-execute-async
client.indices().flushSyncedAsync(request, expectWarnings( client.indices().flushSyncedAsync(request, RequestOptions.DEFAULT, listener); // <1>
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead."
), listener); // <1>
// end::flush-synced-execute-async // end::flush-synced-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS)); assertTrue(latch.await(30L, TimeUnit.SECONDS));

View File

@ -4,10 +4,6 @@
<titleabbrev>Synced flush</titleabbrev> <titleabbrev>Synced flush</titleabbrev>
++++ ++++
deprecated::[7.6, synced-flush is deprecated and will be removed in 8.0.
Use <<indices-flush,flush>> instead. A <<indices-flush,flush>> has the
same effect as a synced flush on Elasticsearch 7.6 or later]
Performs a synced flush on one or more indices. Performs a synced flush on one or more indices.
[source,console] [source,console]

View File

@ -3,12 +3,8 @@
-------------------------------------------------- --------------------------------------------------
POST _flush/synced POST _flush/synced
-------------------------------------------------- --------------------------------------------------
// TEST[skip: will fail as synced flush is deprecated]
When you perform a synced flush, check the response to make sure there are When you perform a synced flush, check the response to make sure there are
no failures. Synced flush operations that fail due to pending indexing no failures. Synced flush operations that fail due to pending indexing
operations are listed in the response body, although the request itself operations are listed in the response body, although the request itself
still returns a 200 OK status. If there are failures, reissue the request. still returns a 200 OK status. If there are failures, reissue the request.
Note that synced flush is deprecated and will be removed in 8.0. A flush
has the same effect as a synced flush on Elasticsearch 7.6 or later.

View File

@ -745,7 +745,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
// We had a bug before where we failed to perform peer recovery with sync_id from 5.x to 6.x. // We had a bug before where we failed to perform peer recovery with sync_id from 5.x to 6.x.
// We added this synced flush so we can exercise different paths of recovery code. // We added this synced flush so we can exercise different paths of recovery code.
try { try {
performSyncedFlush(index); client().performRequest(new Request("POST", index + "/_flush/synced"));
} catch (ResponseException ignored) { } catch (ResponseException ignored) {
// synced flush is optional here // synced flush is optional here
} }

View File

@ -591,7 +591,7 @@ public class RecoveryIT extends AbstractRollingTestCase {
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit. // A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit.
assertBusy(() -> { assertBusy(() -> {
try { try {
Response resp = performSyncedFlush(index); Response resp = client().performRequest(new Request("POST", index + "/_flush/synced"));
Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards"); Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards");
assertThat(result.get("failed"), equalTo(0)); assertThat(result.get("failed"), equalTo(0));
} catch (ResponseException ex) { } catch (ResponseException ex) {

View File

@ -2,7 +2,7 @@
"indices.flush_synced":{ "indices.flush_synced":{
"documentation":{ "documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html", "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html",
"description":"Performs a synced flush operation on one or more indices. Synced flush is deprecated and will be removed in 8.0. Use flush instead" "description":"Performs a synced flush operation on one or more indices."
}, },
"stability":"stable", "stability":"stable",
"url":{ "url":{

View File

@ -88,6 +88,54 @@
- match: - match:
$body: | $body: |
/^$/ /^$/
- do:
indices.create:
index: sync_id_test
body:
settings:
number_of_shards: 5
number_of_replicas: 0
- do:
indices.flush_synced:
index: sync_id_test
- is_false: _shards.failed
- do:
cat.shards:
index: sync_id_test
h: index,state,sync_id
# 20 chars for sync ids with 5.x which uses time-based uuids and 22 with 6.x which uses random uuids
- match:
$body: |
/^(sync_id_test\s+STARTED\s+[A-Za-z0-9_\-]{20,22}\n){5}$/
- do:
indices.delete:
index: sync_id_test
- do:
indices.create:
index: sync_id_no_flush_test
body:
settings:
number_of_shards: 5
number_of_replicas: 0
- do:
cat.shards:
index: sync_id_no_flush_test
h: index,state,sync_id
- match:
$body: |
/^(sync_id_no_flush_test\s+STARTED\s+\n){5}$/
- do:
indices.delete:
index: sync_id_no_flush_test
- do: - do:
indices.create: indices.create:
index: index1 index: index1

View File

@ -1,9 +1,5 @@
--- ---
"Index synced flush rest test": "Index synced flush rest test":
- skip:
version: " - 7.5.99"
reason: "synced flush is deprecated in 7.6"
features: "warnings"
- do: - do:
indices.create: indices.create:
index: testing index: testing
@ -16,8 +12,6 @@
cluster.health: cluster.health:
wait_for_status: green wait_for_status: green
- do: - do:
warnings:
- Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead.
indices.flush_synced: indices.flush_synced:
index: testing index: testing

View File

@ -41,7 +41,6 @@ import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.common.util.concurrent.CountDown; import org.elasticsearch.common.util.concurrent.CountDown;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
@ -72,17 +71,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.stream.StreamSupport;
public class SyncedFlushService implements IndexEventListener { public class SyncedFlushService implements IndexEventListener {
private static final Logger logger = LogManager.getLogger(SyncedFlushService.class); private static final Logger logger = LogManager.getLogger(SyncedFlushService.class);
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(logger);
public static final String SYNCED_FLUSH_DEPRECATION_MESSAGE =
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead.";
private static final String PRE_SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/pre"; private static final String PRE_SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/pre";
private static final String SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/sync"; private static final String SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/sync";
private static final String IN_FLIGHT_OPS_ACTION_NAME = "internal:indices/flush/synced/in_flight"; private static final String IN_FLIGHT_OPS_ACTION_NAME = "internal:indices/flush/synced/in_flight";
@ -137,9 +130,6 @@ public class SyncedFlushService implements IndexEventListener {
IndicesOptions indicesOptions, IndicesOptions indicesOptions,
final ActionListener<SyncedFlushResponse> listener) { final ActionListener<SyncedFlushResponse> listener) {
final ClusterState state = clusterService.state(); final ClusterState state = clusterService.state();
if (StreamSupport.stream(state.nodes().spliterator(), false).allMatch(n -> n.getVersion().onOrAfter(Version.V_7_6_0))) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("synced_flush", SYNCED_FLUSH_DEPRECATION_MESSAGE);
}
final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, indicesOptions, aliasesOrIndices); final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, indicesOptions, aliasesOrIndices);
final Map<String, List<ShardsSyncedFlushResult>> results = ConcurrentCollections.newConcurrentMap(); final Map<String, List<ShardsSyncedFlushResult>> results = ConcurrentCollections.newConcurrentMap();
int numberOfShards = 0; int numberOfShards = 0;

View File

@ -54,7 +54,6 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.internal.io.IOUtils; import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.seqno.ReplicationTracker; import org.elasticsearch.index.seqno.ReplicationTracker;
import org.elasticsearch.indices.flush.SyncedFlushService;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.snapshots.SnapshotState; import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -1223,19 +1222,4 @@ public abstract class ESRestTestCase extends ESTestCase {
assertNotNull(minVersion); assertNotNull(minVersion);
return minVersion; return minVersion;
} }
protected static Response performSyncedFlush(String indexName) throws IOException {
final Request request = new Request("POST", indexName + "/_flush/synced");
final List<String> expectedWarnings = Collections.singletonList(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE);
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_6_0))) {
final Builder options = RequestOptions.DEFAULT.toBuilder();
options.setWarningsHandler(warnings -> warnings.equals(expectedWarnings) == false);
request.setOptions(options);
} else if (nodeVersions.stream().anyMatch(version -> version.onOrAfter(Version.V_7_6_0))) {
final Builder options = RequestOptions.DEFAULT.toBuilder();
options.setWarningsHandler(warnings -> warnings.isEmpty() == false && warnings.equals(expectedWarnings) == false);
request.setOptions(options);
}
return client().performRequest(request);
}
} }