Skip to content

Commit 08b8450

Browse files
committed
Deprecate synced flush (#50835)
A normal flush has the same effect as a synced flush on Elasticsearch 7.6 or later. It's deprecated in 7.6 and will be removed in 8.0. Relates #50776
1 parent 36079d4 commit 08b8450

File tree

13 files changed

+76
-73
lines changed

13 files changed

+76
-73
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ public Cancellable flushAsync(FlushRequest flushRequest, RequestOptions options,
423423
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
424424
* @return the response
425425
* @throws IOException in case there is a problem sending the request or parsing back the response
426+
* @deprecated synced flush is deprecated and will be removed in 8.0.
427+
* Use {@link #flush(FlushRequest, RequestOptions)} instead.
426428
*/
429+
@Deprecated
427430
public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException {
428431
return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,
429432
SyncedFlushResponse::fromXContent, emptySet());
@@ -437,7 +440,10 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re
437440
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
438441
* @param listener the listener to be notified upon request completion
439442
* @return cancellable that may be used to cancel the request
443+
* @deprecated synced flush is deprecated and will be removed in 8.0.
444+
* Use {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} instead.
440445
*/
446+
@Deprecated
441447
public Cancellable flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options,
442448
ActionListener<SyncedFlushResponse> listener) {
443449
return restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
import org.elasticsearch.index.IndexSettings;
9898
import org.elasticsearch.index.query.QueryBuilder;
9999
import org.elasticsearch.index.query.QueryBuilders;
100+
import org.elasticsearch.indices.flush.SyncedFlushService;
100101
import org.elasticsearch.rest.RestStatus;
101102

102103
import java.io.IOException;
@@ -768,7 +769,8 @@ public void testSyncedFlush() throws IOException {
768769
createIndex(index, settings);
769770
SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(index);
770771
SyncedFlushResponse flushResponse =
771-
execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync);
772+
execute(syncedFlushRequest, highLevelClient().indices()::flushSynced, highLevelClient().indices()::flushSyncedAsync,
773+
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE));
772774
assertThat(flushResponse.totalShards(), equalTo(1));
773775
assertThat(flushResponse.successfulShards(), equalTo(1));
774776
assertThat(flushResponse.failedShards(), equalTo(0));
@@ -783,7 +785,8 @@ public void testSyncedFlush() throws IOException {
783785
execute(
784786
syncedFlushRequest,
785787
highLevelClient().indices()::flushSynced,
786-
highLevelClient().indices()::flushSyncedAsync
788+
highLevelClient().indices()::flushSyncedAsync,
789+
expectWarnings(SyncedFlushService.SYNCED_FLUSH_DEPRECATION_MESSAGE)
787790
)
788791
);
789792
assertEquals(RestStatus.NOT_FOUND, exception.status());

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,8 @@ 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-
842+
// Synced flush is deprecated
843+
apiUnsupported.remove("indices.flush_synced");
843844

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

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,9 @@ public void testSyncedFlushIndex() throws Exception {
10181018
// end::flush-synced-request-indicesOptions
10191019

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

10241026
// tag::flush-synced-response
@@ -1062,7 +1064,9 @@ public void onFailure(Exception e) {
10621064
listener = new LatchedActionListener<>(listener, latch);
10631065

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

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

docs/reference/indices/synced-flush.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
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+
711
Performs a synced flush on one or more indices.
812

913
[source,console]

docs/reference/upgrade/synced-flush.asciidoc

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

78
When you perform a synced flush, check the response to make sure there are
89
no failures. Synced flush operations that fail due to pending indexing
910
operations are listed in the response body, although the request itself
1011
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public void testRecovery() throws Exception {
684684
// We had a bug before where we failed to perform peer recovery with sync_id from 5.x to 6.x.
685685
// We added this synced flush so we can exercise different paths of recovery code.
686686
try {
687-
client().performRequest(new Request("POST", index + "/_flush/synced"));
687+
performSyncedFlush(index);
688688
} catch (ResponseException ignored) {
689689
// synced flush is optional here
690690
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ private void syncedFlush(String index) throws Exception {
562562
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit.
563563
assertBusy(() -> {
564564
try {
565-
Response resp = client().performRequest(new Request("POST", index + "/_flush/synced"));
565+
Response resp = performSyncedFlush(index);
566566
Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards");
567567
assertThat(result.get("failed"), equalTo(0));
568568
} catch (ResponseException ex) {

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

Lines changed: 1 addition & 1 deletion
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."
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"
66
},
77
"stability":"stable",
88
"url":{

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

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -88,54 +88,6 @@
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-
13991
- do:
14092
indices.create:
14193
index: index1

0 commit comments

Comments
 (0)