-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Shadow replicas on shared filesystems #9727
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
Closed
Closed
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
05975af
Add ShadowEngine
dakrone 38135af
make tests pass
s1monw 7fcb373
make test more evil
s1monw be02cab
Add test that restarts nodes to ensure shadow replicas recover
dakrone 343dc0b
long adder is not available in java7
s1monw 2a2eed1
Merge branch 'master' into shadow-replicas
s1monw 24d36c9
utilize the new delete code
s1monw 2d42736
shortcut recovery if we are on a shared FS - no need to compare files…
s1monw ca9beb2
Merge branch 'master' into shadow-replicas
s1monw 67d7df4
Add start of ShadowEngine unit tests
dakrone 1896fed
Add testShadowEngineIgnoresWriteOperations and testSearchResultRelease
dakrone a95adbe
Remove tests that don't apply to ShadowEngine
dakrone 52e9cd1
Add a test for replica -> primary promotion
dakrone 2378fbb
Fix missing import
dakrone 5e33eea
Remove overly-complex test
dakrone 80cf0e8
Remove nocommit in ShadowEngineTests#testFailStart()
dakrone e4dbfb0
Fix segment info for ShadowEngine, remove test nocommit
dakrone 06e2eb4
Add a test checking that indices with shadow replicas clean up after …
dakrone fdbe413
Use check for shared filesystem in primary -> primary relocation
dakrone 5689b7d
Add testShadowReplicaNaturalRelocation
dakrone cf2fb80
Make assertPathHasBeenCleared recursive
dakrone 4a367c0
fix primary promotion
s1monw f229719
first cut at catchup from primary
s1monw abda780
Merge branch 'master' into shadow-replicas
s1monw a62b9a7
fix compile error after upstream changes
s1monw a7eb53c
Simplify shared filesystem recovery by using a dedicated recovery han…
s1monw d8d59db
Refactor more shared methods into the abstract Engine
dakrone 28a9d18
Remove nocommit, document canDeleteIndexContents
dakrone 4f71c8d
Add documentation to ShadowEngine
dakrone ea4e3e5
Add documentation to ShadowIndexShard, remove nocommit
dakrone aea9692
revert unneeded changes on Store
s1monw 83d171c
Merge branch 'master' into shadow-replicas
s1monw 213292e
add one more nocommit
s1monw e5bc047
Don't replicate document request when using shadow replicas
dakrone 740c28d
Merge branch 'master' into shadow-replicas
dakrone 2ae80f9
throw UnsupportedOperationException on write operations in ShadowEngine
dakrone c4c999d
Merge branch 'master' into shadow-replicas
s1monw 28f069b
fix primary relocation
s1monw 82b9f04
reduce the changes compared to master
s1monw abb6965
remove nocommit and simplify delete logic
s1monw d77414c
remove nocommits in IndexMetaData
s1monw 48a700d
add test for failing shadow engine / remove nocommit
s1monw e8ad614
Merge branch 'master' into shadow-replicas
s1monw 77fba57
Merge branch 'master' into shadow-replicas
s1monw 11886b7
Back out non-shared FS code. this will go in in a second iteration
s1monw 744f228
revert changes to IndexShardGateway - these are leftovers from previo…
s1monw 45cd34a
fix tests
s1monw c5ece6d
simplify shadow engine
s1monw eb699c1
remove last nocommit
s1monw 4473e63
Add asciidoc documentation for shadow replicas
dakrone b9d1fed
Merge remote-tracking branch 'refs/remotes/origin/master' into shadow…
dakrone 0b1b852
Merge remote-tracking branch 'refs/remotes/origin/master' into shadow…
dakrone a1b8b8c
Remove unused import and fix index creation example in docs
dakrone b64fef1
Add warning that predefined mappings should be used
dakrone 23001af
Remove ShadowEngineFactory, add .newReadOnlyEngine method in EngineFa…
dakrone d90d698
Rename `ownsShard` to `canDeleteShardContent`
dakrone 7346f9f
Revert changes to RecoveryTarget.java
dakrone 60a4d53
Add a test for shadow replicas that uses field data
dakrone c8e8db4
Clarify comment about pre-defined mappings
dakrone 73c62df
Add MockShadowEngine and hook it up to be used
dakrone 1a0d456
Rename usesSharedFilesystem -> isOnSharedFilesystem
dakrone 62b0c28
Use IndexMetaData.isIndexUsingShadowReplicas helper
dakrone 67a797a
Factor out AssertingSearcher so it can be used by mock Engines
dakrone edd4943
Move engine creation into protected createNewEngine method
dakrone 325acbe
Use ?preference=_primary automatically for realtime GET operations
dakrone 2083503
Use Enum for "_primary" preference
dakrone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| [[indices-shadow-replicas]] | ||
| == Shadow replica indices | ||
|
|
||
| experimental[] | ||
|
|
||
| If you would like to use a shared filesystem, you can use the shadow replicas | ||
| settings to choose where on disk the data for an index should be kept, as well | ||
| as how Elasticsearch should replay operations on all the replica shards of an | ||
| index. | ||
|
|
||
| In order to fully utilize the `index.data_path` and `index.shadow_replicas` | ||
| settings, you need to enable using it in elasticsearch.yml: | ||
|
|
||
| [source,yaml] | ||
| -------------------------------------------------- | ||
| node.enable_custom_paths: true | ||
| -------------------------------------------------- | ||
|
|
||
| You can then create an index with a custom data path, where each node will use | ||
| this path for the data: | ||
|
|
||
| [WARNING] | ||
| ======================== | ||
| Because shadow replicas do not index the document on replica shards, it's | ||
| possible for the replica's known mapping to be behind the index's known mapping | ||
| if the latest cluster state has not yet been processed on the node containing | ||
| the replica. Because of this, it is highly recommended to use pre-defined | ||
| mappings when using shadow replicas. | ||
| ======================== | ||
|
|
||
| [source,js] | ||
| -------------------------------------------------- | ||
| curl -XPUT 'localhost:9200/my_index' -d ' | ||
| { | ||
| "index" : { | ||
| "number_of_shards" : 1, | ||
| "number_of_replicas" : 4, | ||
| "data_path": "/var/data/my_index", | ||
| "shadow_replicas": true | ||
| } | ||
| }' | ||
| -------------------------------------------------- | ||
|
|
||
| [WARNING] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should leave a note about the limitation of the replicas being behind mapping wise?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a section to the documentation on this. |
||
| ======================== | ||
| In the above example, the "/var/data/my_index" path is a shared filesystem that | ||
| must be available on every node in the Elasticsearch cluster. You must also | ||
| ensure that the Elasticsearch process has the correct permissions to read from | ||
| and write to the directory used in the `index.data_path` setting. | ||
| ======================== | ||
|
|
||
| An index that has been created with the `index.shadow_replicas` setting set to | ||
| "true" will not replicate document operations to any of the replica shards, | ||
| instead, it will only continually refresh. Once segments are available on the | ||
| filesystem where the shadow replica resides (after an Elasticsearch "flush"), a | ||
| regular refresh (governed by the `index.refresh_interval`) can be used to make | ||
| the new data searchable. | ||
|
|
||
| NOTE: Since documents are only indexed on the primary shard, realtime GET | ||
| requests could fail to return a document if executed on the replica shard, | ||
| therefore, GET API requests automatically have the `?preference=_primary` flag | ||
| set if there is no preference flag already set. | ||
|
|
||
| In order to ensure the data is being synchronized in a fast enough manner, you | ||
| may need to tune the flush threshold for the index to a desired number. A flush | ||
| is needed to fsync segment files to disk, so they will be visible to all other | ||
| replica nodes. Users should test what flush threshold levels they are | ||
| comfortable with, as increased flushing can impact indexing performance. | ||
|
|
||
| The Elasticsearch cluster will still detect the loss of a primary shard, and | ||
| transform the replica into a primary in this situation. This transformation will | ||
| take slightly longer, since no `IndexWriter` is maintained for each shadow | ||
| replica. | ||
|
|
||
| Below is the list of settings that can be changed using the update | ||
| settings API: | ||
|
|
||
| `index.data_path` (string):: | ||
| Path to use for the index's data. Note that by default Elasticsearch will | ||
| append the node ordinal by default to the path to ensure multiple instances | ||
| of Elasticsearch on the same machine do not share a data directory. | ||
|
|
||
| `index.shadow_replicas`:: | ||
| Boolean value indicating this index should use shadow replicas. Defaults to | ||
| `false`. | ||
|
|
||
| `index.shared_filesystem`:: | ||
| Boolean value indicating this index uses a shared filesystem. Defaults to | ||
| the `true` if `index.shadow_replicas` is set to true, `false` otherwise. | ||
|
|
||
| === Node level settings related to shadow replicas | ||
|
|
||
| These are non-dynamic settings that need to be configured in `elasticsearch.yml` | ||
|
|
||
| `node.add_id_to_custom_path`:: | ||
| Boolean setting indicating whether Elasticsearch should append the node's | ||
| ordinal to the custom data path. For example, if this is enabled and a path | ||
| of "/tmp/foo" is used, the first locally-running node will use "/tmp/foo/0", | ||
| the second will use "/tmp/foo/1", the third "/tmp/foo/2", etc. Defaults to | ||
| `true`. | ||
|
|
||
| `node.enable_custom_paths`:: | ||
| Boolean value that must be set to `true` in order to use the | ||
| `index.data_path` setting. Defaults to `false`. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for this!