Skip to content

Commit a9335ca

Browse files
authored
[DOCS] Separate and reformat synced flush API docs (#46634) (#46841)
1 parent a9312f3 commit a9335ca

File tree

5 files changed

+295
-195
lines changed

5 files changed

+295
-195
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public void flushAsync(FlushRequest flushRequest, RequestOptions options, Action
569569

570570
/**
571571
* Initiate a synced flush manually using the synced flush API.
572-
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html#synced-flush-api">
572+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html">
573573
* Synced flush API on elastic.co</a>
574574
* @param syncedFlushRequest the request
575575
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
@@ -583,7 +583,7 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re
583583

584584
/**
585585
* Asynchronously initiate a synced flush manually using the synced flush API.
586-
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html#synced-flush-api">
586+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html">
587587
* Synced flush API on elastic.co</a>
588588
* @param syncedFlushRequest the request
589589
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized

docs/reference/indices.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ index settings, aliases, mappings, and index templates.
6868
* <<indices-clearcache>>
6969
* <<indices-refresh>>
7070
* <<indices-flush>>
71+
* <<indices-synced-flush-api>>
7172
* <<indices-forcemerge>>
7273

7374
include::indices/create-index.asciidoc[]
@@ -136,6 +137,8 @@ include::indices/clearcache.asciidoc[]
136137

137138
include::indices/flush.asciidoc[]
138139

140+
include::indices/synced-flush.asciidoc[]
141+
139142
include::indices/refresh.asciidoc[]
140143

141144
include::indices/forcemerge.asciidoc[]

docs/reference/indices/flush.asciidoc

Lines changed: 3 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -47,198 +47,9 @@ POST _flush
4747
// CONSOLE
4848
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
4949

50-
[[synced-flush-api]]
51-
==== Synced Flush
52-
53-
Elasticsearch tracks the indexing activity of each shard. Shards that have not
54-
received any indexing operations for 5 minutes are automatically marked as inactive. This presents
55-
an opportunity for Elasticsearch to reduce shard resources and also perform
56-
a special kind of flush, called `synced flush`. A synced flush performs a normal flush, then adds
57-
a generated unique marker (sync_id) to all shards.
58-
59-
Since the sync id marker was added when there were no ongoing indexing operations, it can
60-
be used as a quick way to check if the two shards' lucene indices are identical. This quick sync id
61-
comparison (if present) is used during recovery or restarts to skip the first and
62-
most costly phase of the process. In that case, no segment files need to be copied and
63-
the transaction log replay phase of the recovery can start immediately. Note that since the sync id
64-
marker was applied together with a flush, it is very likely that the transaction log will be empty,
65-
speeding up recoveries even more.
66-
67-
This is particularly useful for use cases having lots of indices which are
68-
never or very rarely updated, such as time based data. This use case typically generates lots of indices whose
69-
recovery without the synced flush marker would take a long time.
70-
71-
To check whether a shard has a marker or not, look for the `commit` section of shard stats returned by
72-
the <<indices-stats,indices stats>> API:
73-
74-
[source,sh]
75-
--------------------------------------------------
76-
GET twitter/_stats?filter_path=**.commit&level=shards <1>
77-
--------------------------------------------------
78-
// CONSOLE
79-
// TEST[s/^/PUT twitter\nPOST twitter\/_flush\/synced\n/]
80-
<1> `filter_path` is used to reduce the verbosity of the response, but is entirely optional
81-
82-
83-
which returns something similar to:
84-
85-
[source,js]
86-
--------------------------------------------------
87-
{
88-
"indices": {
89-
"twitter": {
90-
"shards": {
91-
"0": [
92-
{
93-
"commit" : {
94-
"id" : "3M3zkw2GHMo2Y4h4/KFKCg==",
95-
"generation" : 3,
96-
"user_data" : {
97-
"translog_uuid" : "hnOG3xFcTDeoI_kvvvOdNA",
98-
"history_uuid" : "XP7KDJGiS1a2fHYiFL5TXQ",
99-
"local_checkpoint" : "-1",
100-
"translog_generation" : "2",
101-
"max_seq_no" : "-1",
102-
"sync_id" : "AVvFY-071siAOuFGEO9P", <1>
103-
"max_unsafe_auto_id_timestamp" : "-1",
104-
"min_retained_seq_no" : "0"
105-
},
106-
"num_docs" : 0
107-
}
108-
}
109-
]
110-
}
111-
}
112-
}
113-
}
114-
--------------------------------------------------
115-
// TESTRESPONSE[s/"id" : "3M3zkw2GHMo2Y4h4\/KFKCg=="/"id": $body.indices.twitter.shards.0.0.commit.id/]
116-
// TESTRESPONSE[s/"translog_uuid" : "hnOG3xFcTDeoI_kvvvOdNA"/"translog_uuid": $body.indices.twitter.shards.0.0.commit.user_data.translog_uuid/]
117-
// TESTRESPONSE[s/"history_uuid" : "XP7KDJGiS1a2fHYiFL5TXQ"/"history_uuid": $body.indices.twitter.shards.0.0.commit.user_data.history_uuid/]
118-
// TESTRESPONSE[s/"sync_id" : "AVvFY-071siAOuFGEO9P"/"sync_id": $body.indices.twitter.shards.0.0.commit.user_data.sync_id/]
119-
<1> the `sync id` marker
12050

12151
[float]
122-
==== Synced Flush API
123-
124-
The Synced Flush API allows an administrator to initiate a synced flush manually. This can be particularly useful for
125-
a planned (rolling) cluster restart where you can stop indexing and don't want to wait the default 5 minutes for
126-
idle indices to be sync-flushed automatically.
127-
128-
While handy, there are a couple of caveats for this API:
129-
130-
1. Synced flush is a best effort operation. Any ongoing indexing operations will cause
131-
the synced flush to fail on that shard. This means that some shards may be synced flushed while others aren't. See below for more.
132-
2. The `sync_id` marker is removed as soon as the shard is flushed again. That is because a flush replaces the low level
133-
lucene commit point where the marker is stored. Uncommitted operations in the transaction log do not remove the marker.
134-
In practice, one should consider any indexing operation on an index as removing the marker as a flush can be triggered by Elasticsearch
135-
at any time.
136-
137-
138-
NOTE: It is harmless to request a synced flush while there is ongoing indexing. Shards that are idle will succeed and shards
139-
that are not will fail. Any shards that succeeded will have faster recovery times.
140-
141-
142-
[source,sh]
143-
--------------------------------------------------
144-
POST twitter/_flush/synced
145-
--------------------------------------------------
146-
// CONSOLE
147-
// TEST[setup:twitter]
148-
149-
The response contains details about how many shards were successfully sync-flushed and information about any failure.
150-
151-
Here is what it looks like when all shards of a two shards and one replica index successfully
152-
sync-flushed:
153-
154-
[source,js]
155-
--------------------------------------------------
156-
{
157-
"_shards": {
158-
"total": 2,
159-
"successful": 2,
160-
"failed": 0
161-
},
162-
"twitter": {
163-
"total": 2,
164-
"successful": 2,
165-
"failed": 0
166-
}
167-
}
168-
--------------------------------------------------
169-
// TESTRESPONSE[s/"successful": 2/"successful": 1/]
170-
171-
Here is what it looks like when one shard group failed due to pending operations:
172-
173-
[source,js]
174-
--------------------------------------------------
175-
{
176-
"_shards": {
177-
"total": 4,
178-
"successful": 2,
179-
"failed": 2
180-
},
181-
"twitter": {
182-
"total": 4,
183-
"successful": 2,
184-
"failed": 2,
185-
"failures": [
186-
{
187-
"shard": 1,
188-
"reason": "[2] ongoing operations on primary"
189-
}
190-
]
191-
}
192-
}
193-
--------------------------------------------------
194-
// NOTCONSOLE
195-
196-
NOTE: The above error is shown when the synced flush fails due to concurrent indexing operations. The HTTP
197-
status code in that case will be `409 CONFLICT`.
198-
199-
Sometimes the failures are specific to a shard copy. The copies that failed will not be eligible for
200-
fast recovery but those that succeeded still will be. This case is reported as follows:
201-
202-
[source,js]
203-
--------------------------------------------------
204-
{
205-
"_shards": {
206-
"total": 4,
207-
"successful": 1,
208-
"failed": 1
209-
},
210-
"twitter": {
211-
"total": 4,
212-
"successful": 3,
213-
"failed": 1,
214-
"failures": [
215-
{
216-
"shard": 1,
217-
"reason": "unexpected error",
218-
"routing": {
219-
"state": "STARTED",
220-
"primary": false,
221-
"node": "SZNr2J_ORxKTLUCydGX4zA",
222-
"relocating_node": null,
223-
"shard": 1,
224-
"index": "twitter"
225-
}
226-
}
227-
]
228-
}
229-
}
230-
--------------------------------------------------
231-
// NOTCONSOLE
232-
233-
NOTE: When a shard copy fails to sync-flush, the HTTP status code returned will be `409 CONFLICT`.
234-
235-
The synced flush API can be applied to more than one index with a single call,
236-
or even on `_all` the indices.
237-
238-
[source,js]
239-
--------------------------------------------------
240-
POST kimchy,elasticsearch/_flush/synced
52+
[[synced-flush-api]]
53+
==== Synced Flush
24154

242-
POST _flush/synced
243-
--------------------------------------------------
244-
// CONSOLE
55+
See <<indices-synced-flush-api>>.

0 commit comments

Comments
 (0)