Skip to content

Commit 05f97d5

Browse files
committed
Revert "Deprecate synced flush (#50835)"
This reverts commit 1a32d71.
1 parent d1bde0a commit 05f97d5

File tree

13 files changed

+73
-79
lines changed

13 files changed

+73
-79
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java

-6
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,7 @@ public Cancellable flushAsync(FlushRequest flushRequest, RequestOptions options,
601601
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
602602
* @return the response
603603
* @throws IOException in case there is a problem sending the request or parsing back the response
604-
* @deprecated synced flush is deprecated and will be removed in 8.0.
605-
* Use {@link #flush(FlushRequest, RequestOptions)} instead.
606604
*/
607-
@Deprecated
608605
public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException {
609606
return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,
610607
SyncedFlushResponse::fromXContent, emptySet());
@@ -618,10 +615,7 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re
618615
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
619616
* @param listener the listener to be notified upon request completion
620617
* @return cancellable that may be used to cancel the request
621-
* @deprecated synced flush is deprecated and will be removed in 8.0.
622-
* Use {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} instead.
623618
*/
624-
@Deprecated
625619
public Cancellable flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options,
626620
ActionListener<SyncedFlushResponse> listener) {
627621
return restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,

client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
import org.elasticsearch.index.mapper.MapperService;
101101
import org.elasticsearch.index.query.QueryBuilder;
102102
import org.elasticsearch.index.query.QueryBuilders;
103-
import org.elasticsearch.indices.flush.SyncedFlushService;
104103
import org.elasticsearch.rest.RestStatus;
105104
import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
106105
import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction;
@@ -983,8 +982,7 @@ public void testSyncedFlush() throws IOException {
983982
createIndex(index, settings);
984983
SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(index);
985984
SyncedFlushResponse flushResponse =
986-
execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync,
987-
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE));
985+
execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync);
988986
assertThat(flushResponse.totalShards(), equalTo(1));
989987
assertThat(flushResponse.successfulShards(), equalTo(1));
990988
assertThat(flushResponse.failedShards(), equalTo(0));
@@ -999,8 +997,7 @@ public void testSyncedFlush() throws IOException {
999997
execute(
1000998
syncedFlushRequest,
1001999
highLevelClient().indices()::flushSynced,
1002-
highLevelClient().indices()::flushSyncedAsync,
1003-
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE)
1000+
highLevelClient().indices()::flushSyncedAsync
10041001
)
10051002
);
10061003
assertEquals(RestStatus.NOT_FOUND, exception.status());

client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,7 @@ public void testApiNamingConventions() throws Exception {
839839
// looking like it doesn't have a valid implementatation when it does.
840840
apiUnsupported.remove("indices.get_template");
841841

842-
// Synced flush is deprecated
843-
apiUnsupported.remove("indices.flush_synced");
842+
844843

845844
for (Map.Entry<String, Set<Method>> entry : methods.entrySet()) {
846845
String apiName = entry.getKey();

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,7 @@ public void testSyncedFlushIndex() throws Exception {
10191019
// end::flush-synced-request-indicesOptions
10201020

10211021
// tag::flush-synced-execute
1022-
SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request, expectWarnings(
1023-
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead."
1024-
));
1022+
SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request, RequestOptions.DEFAULT);
10251023
// end::flush-synced-execute
10261024

10271025
// tag::flush-synced-response
@@ -1065,9 +1063,7 @@ public void onFailure(Exception e) {
10651063
listener = new LatchedActionListener<>(listener, latch);
10661064

10671065
// tag::flush-synced-execute-async
1068-
client.indices().flushSyncedAsync(request, expectWarnings(
1069-
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead."
1070-
), listener); // <1>
1066+
client.indices().flushSyncedAsync(request, RequestOptions.DEFAULT, listener); // <1>
10711067
// end::flush-synced-execute-async
10721068

10731069
assertTrue(latch.await(30L, TimeUnit.SECONDS));

docs/reference/indices/synced-flush.asciidoc

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
<titleabbrev>Synced flush</titleabbrev>
55
++++
66

7-
deprecated::[7.6, synced-flush is deprecated and will be removed in 8.0.
8-
Use <<indices-flush,flush>> instead. A <<indices-flush,flush>> has the
9-
same effect as a synced flush on Elasticsearch 7.6 or later]
10-
117
Performs a synced flush on one or more indices.
128

139
[source,console]

docs/reference/upgrade/synced-flush.asciidoc

-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
--------------------------------------------------
44
POST _flush/synced
55
--------------------------------------------------
6-
// TEST[skip: will fail as synced flush is deprecated]
76

87
When you perform a synced flush, check the response to make sure there are
98
no failures. Synced flush operations that fail due to pending indexing
109
operations are listed in the response body, although the request itself
1110
still returns a 200 OK status. If there are failures, reissue the request.
12-
13-
Note that synced flush is deprecated and will be removed in 8.0. A flush
14-
has the same effect as a synced flush on Elasticsearch 7.6 or later.

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public void testRecovery() throws Exception {
745745
// We had a bug before where we failed to perform peer recovery with sync_id from 5.x to 6.x.
746746
// We added this synced flush so we can exercise different paths of recovery code.
747747
try {
748-
performSyncedFlush(index);
748+
client().performRequest(new Request("POST", index + "/_flush/synced"));
749749
} catch (ResponseException ignored) {
750750
// synced flush is optional here
751751
}

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ private void syncedFlush(String index) throws Exception {
591591
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit.
592592
assertBusy(() -> {
593593
try {
594-
Response resp = performSyncedFlush(index);
594+
Response resp = client().performRequest(new Request("POST", index + "/_flush/synced"));
595595
Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards");
596596
assertThat(result.get("failed"), equalTo(0));
597597
} catch (ResponseException ex) {

rest-api-spec/src/main/resources/rest-api-spec/api/indices.flush_synced.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"indices.flush_synced":{
33
"documentation":{
44
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html",
5-
"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"
5+
"description":"Performs a synced flush operation on one or more indices."
66
},
77
"stability":"stable",
88
"url":{

rest-api-spec/src/main/resources/rest-api-spec/test/cat.shards/10_basic.yml

+48
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,54 @@
8888
- match:
8989
$body: |
9090
/^$/
91+
92+
- do:
93+
indices.create:
94+
index: sync_id_test
95+
body:
96+
settings:
97+
number_of_shards: 5
98+
number_of_replicas: 0
99+
100+
- do:
101+
indices.flush_synced:
102+
index: sync_id_test
103+
104+
- is_false: _shards.failed
105+
106+
- do:
107+
cat.shards:
108+
index: sync_id_test
109+
h: index,state,sync_id
110+
# 20 chars for sync ids with 5.x which uses time-based uuids and 22 with 6.x which uses random uuids
111+
- match:
112+
$body: |
113+
/^(sync_id_test\s+STARTED\s+[A-Za-z0-9_\-]{20,22}\n){5}$/
114+
115+
- do:
116+
indices.delete:
117+
index: sync_id_test
118+
119+
- do:
120+
indices.create:
121+
index: sync_id_no_flush_test
122+
body:
123+
settings:
124+
number_of_shards: 5
125+
number_of_replicas: 0
126+
127+
- do:
128+
cat.shards:
129+
index: sync_id_no_flush_test
130+
h: index,state,sync_id
131+
- match:
132+
$body: |
133+
/^(sync_id_no_flush_test\s+STARTED\s+\n){5}$/
134+
135+
- do:
136+
indices.delete:
137+
index: sync_id_no_flush_test
138+
91139
- do:
92140
indices.create:
93141
index: index1

rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
---
22
"Index synced flush rest test":
3-
- skip:
4-
version: " - 7.5.99"
5-
reason: "synced flush is deprecated in 7.6"
6-
features: "warnings"
7-
- do:
8-
indices.create:
9-
index: testing
10-
body:
11-
settings:
12-
index:
13-
number_of_replicas: 0
3+
- do:
4+
indices.create:
5+
index: testing
6+
body:
7+
settings:
8+
index:
9+
number_of_replicas: 0
1410

15-
- do:
16-
cluster.health:
17-
wait_for_status: green
18-
- do:
19-
warnings:
20-
- Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead.
21-
indices.flush_synced:
22-
index: testing
11+
- do:
12+
cluster.health:
13+
wait_for_status: green
14+
- do:
15+
indices.flush_synced:
16+
index: testing
2317

24-
- is_false: _shards.failed
18+
- is_false: _shards.failed
2519

26-
- do:
27-
indices.stats: {level: shards}
20+
- do:
21+
indices.stats: {level: shards}
2822

29-
- is_true: indices.testing.shards.0.0.commit.user_data.sync_id
23+
- is_true: indices.testing.shards.0.0.commit.user_data.sync_id
3024

3125
---
3226
"Flush stats":

server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java

-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.elasticsearch.common.inject.Inject;
4242
import org.elasticsearch.common.io.stream.StreamInput;
4343
import org.elasticsearch.common.io.stream.StreamOutput;
44-
import org.elasticsearch.common.logging.DeprecationLogger;
4544
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
4645
import org.elasticsearch.common.util.concurrent.CountDown;
4746
import org.elasticsearch.index.Index;
@@ -72,17 +71,11 @@
7271
import java.util.List;
7372
import java.util.Map;
7473
import java.util.concurrent.ConcurrentMap;
75-
import java.util.stream.StreamSupport;
7674

7775
public class SyncedFlushService implements IndexEventListener {
7876

7977
private static final Logger logger = LogManager.getLogger(SyncedFlushService.class);
8078

81-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(logger);
82-
83-
public static final String SYNCED_FLUSH_DEPRECATION_MESSAGE =
84-
"Synced flush is deprecated and will be removed in 8.0. Use flush at _/flush or /{index}/_flush instead.";
85-
8679
private static final String PRE_SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/pre";
8780
private static final String SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/sync";
8881
private static final String IN_FLIGHT_OPS_ACTION_NAME = "internal:indices/flush/synced/in_flight";
@@ -137,9 +130,6 @@ public void attemptSyncedFlush(final String[] aliasesOrIndices,
137130
IndicesOptions indicesOptions,
138131
final ActionListener<SyncedFlushResponse> listener) {
139132
final ClusterState state = clusterService.state();
140-
if (StreamSupport.stream(state.nodes().spliterator(), false).allMatch(n -> n.getVersion().onOrAfter(Version.V_7_6_0))) {
141-
DEPRECATION_LOGGER.deprecatedAndMaybeLog("synced_flush", SYNCED_FLUSH_DEPRECATION_MESSAGE);
142-
}
143133
final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, indicesOptions, aliasesOrIndices);
144134
final Map<String, List<ShardsSyncedFlushResult>> results = ConcurrentCollections.newConcurrentMap();
145135
int numberOfShards = 0;

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

-16
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import org.elasticsearch.core.internal.io.IOUtils;
5555
import org.elasticsearch.index.IndexSettings;
5656
import org.elasticsearch.index.seqno.ReplicationTracker;
57-
import org.elasticsearch.indices.flush.SyncedFlushService;
5857
import org.elasticsearch.rest.RestStatus;
5958
import org.elasticsearch.snapshots.SnapshotState;
6059
import org.elasticsearch.test.ESTestCase;
@@ -1223,19 +1222,4 @@ protected static Version minimumNodeVersion() throws IOException {
12231222
assertNotNull(minVersion);
12241223
return minVersion;
12251224
}
1226-
1227-
protected static Response performSyncedFlush(String indexName) throws IOException {
1228-
final Request request = new Request("POST", indexName + "/_flush/synced");
1229-
final List<String> expectedWarnings = Collections.singletonList(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE);
1230-
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_6_0))) {
1231-
final Builder options = RequestOptions.DEFAULT.toBuilder();
1232-
options.setWarningsHandler(warnings -> warnings.equals(expectedWarnings) == false);
1233-
request.setOptions(options);
1234-
} else if (nodeVersions.stream().anyMatch(version -> version.onOrAfter(Version.V_7_6_0))) {
1235-
final Builder options = RequestOptions.DEFAULT.toBuilder();
1236-
options.setWarningsHandler(warnings -> warnings.isEmpty() == false && warnings.equals(expectedWarnings) == false);
1237-
request.setOptions(options);
1238-
}
1239-
return client().performRequest(request);
1240-
}
12411225
}

0 commit comments

Comments
 (0)