-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Add _source
-only snapshot repository
#32844
Merged
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
08b0cfd
Add `_source`-only snapshot repository
s1monw 3c5a0ed
add license
s1monw 0645159
fix docs test setup
s1monw b28407f
fix imports
s1monw 5cca4c2
make sure on local reindex we don't parse the source if it's not nece…
s1monw 6fc9664
remove dead code
s1monw d32bc05
Merge branch 'master' into source_only_snap
s1monw ea806bc
fix imports
s1monw 02aecd7
status quo
s1monw 8e612f6
Merge branch 'master' into source_only_snap
s1monw 7dcc25d
iteration
s1monw 81c8127
Restore from a soruce only snap by copying only the source
s1monw 6dcf9e5
Merge branch 'master' into source_only_snap
s1monw ee8a9d5
fix imports and docs
s1monw 40cd45d
fix constant
s1monw deff31d
add license headers
s1monw eea9f6f
fix javadocs
s1monw 61c2ff2
Merge branch 'master' into source_only_snap
s1monw dc679c2
Fix stuff after soft deletes are first class citizen
s1monw de30a8f
move searcher creation to engine adn acquire write lock
s1monw 6d63b41
fix tests
s1monw f5e7f70
fix tests
s1monw 6975c82
fix test again
s1monw 4825da2
Merge branch 'master' into source_only_snap
s1monw 70395be
fix settings
s1monw 82042ce
Merge branch 'master' into source_only_snap
s1monw 134bcf5
fix compilation
s1monw efb9303
fix test after lucene upgrade
s1monw d682548
remove routing invariant
s1monw 1ae023f
add comment about soft deletes
s1monw 506c68b
remove TODO
s1monw eec9f18
make flush a no-op
s1monw 02405d4
Merge branch 'master' into source_only_snap
s1monw df925d7
integrate read-only engine
s1monw afba90e
fix compilation
s1monw b615020
bootstrap source only shards with new UUID and localCheckpoint == maxDoc
s1monw 2625996
fix imports
s1monw 140eb50
move all actions to the snapshot creation side
s1monw 14f7caa
rework docs
s1monw d69f675
fix line len
s1monw 7c9b5eb
add source only snap docs
s1monw fe817ca
add xpack role to docs
s1monw 59e5dbf
fix docs tests
s1monw 12473d5
reword docs
s1monw 71d2e58
fix nit
s1monw 5be8844
apply feedback
s1monw 18c4680
Make sure all queries and get requests other than match_all fail
s1monw f384028
fix comment
s1monw 9930e08
Merge branch 'master' into source_only_snap
s1monw 8877497
fix tests to expect exception on query
s1monw 78de6b5
fix imports
s1monw 5f6529f
add test that slices work too
s1monw 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 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,39 @@ | ||
[[repository-src-only]] | ||
=== Source Only Repository | ||
|
||
The Source Only repository adds support for creating `_source` only snapshots using any other | ||
available repository as it's storage backend. This allows using {ref}/modules-snapshots.html[Snapshot/Restore] | ||
to create incremental, storage optimized, and minimal snapshots of an index. | ||
|
||
|
||
[[repository-src-only-usage]] | ||
==== Configuration | ||
|
||
The `_source` only repository always requires a delegate repository to be used as it's storage backend. | ||
In order to use the `fs` respository: | ||
|
||
[source,js] | ||
----------------------------------- | ||
PUT _snapshot/my_src-only_repository | ||
{ | ||
"type": "source", | ||
"settings": { | ||
"delegate_type": "fs", | ||
"location": "my_backup_location" | ||
} | ||
} | ||
----------------------------------- | ||
// CONSOLE | ||
// TESTSETUP | ||
|
||
Since the `_source` only repository doesn't snapshot any index or doc-values structures but only stored | ||
fields and index metadata, it's required to reindex the data during the restore process. This can either happen | ||
as a full re-index based on the mapping of the original index or in a minimal form were only the internal data-structures | ||
are recreated like the `_id` field in order to update the index. The latter can be configured in the repository settings | ||
by setting `"minimal": true`. This allows updates and get operations but won't allow for aggregations or searches. | ||
|
||
A minimal restore is useful if the data is only needed to be re-indexed into another index or if individual documents should be | ||
modified or deleted. | ||
|
||
During restore the re-indexing progress can be monitored via <<indices-recovery,recovery>> API that shows the per-document progress | ||
under the `translog` recovery phase. |
This file contains 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 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
154 changes: 154 additions & 0 deletions
154
server/src/main/java/org/elasticsearch/repositories/FilterRepository.java
This file contains 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,154 @@ | ||
package org.elasticsearch.repositories; | ||
|
||
import org.apache.lucene.index.IndexCommit; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.cluster.metadata.MetaData; | ||
import org.elasticsearch.cluster.metadata.RepositoryMetaData; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.common.component.Lifecycle; | ||
import org.elasticsearch.common.component.LifecycleListener; | ||
import org.elasticsearch.index.shard.IndexShard; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus; | ||
import org.elasticsearch.index.store.Store; | ||
import org.elasticsearch.indices.recovery.RecoveryState; | ||
import org.elasticsearch.snapshots.SnapshotId; | ||
import org.elasticsearch.snapshots.SnapshotInfo; | ||
import org.elasticsearch.snapshots.SnapshotShardFailure; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class FilterRepository implements Repository { | ||
|
||
private final Repository in; | ||
|
||
public FilterRepository(Repository in) { | ||
this.in = in; | ||
} | ||
|
||
@Override | ||
public RepositoryMetaData getMetadata() { | ||
return in.getMetadata(); | ||
} | ||
|
||
@Override | ||
public SnapshotInfo getSnapshotInfo(SnapshotId snapshotId) { | ||
return in.getSnapshotInfo(snapshotId); | ||
} | ||
|
||
@Override | ||
public MetaData getSnapshotGlobalMetaData(SnapshotId snapshotId) { | ||
return in.getSnapshotGlobalMetaData(snapshotId); | ||
} | ||
|
||
@Override | ||
public IndexMetaData getSnapshotIndexMetaData(SnapshotId snapshotId, IndexId index) throws IOException { | ||
return in.getSnapshotIndexMetaData(snapshotId, index); | ||
} | ||
|
||
@Override | ||
public RepositoryData getRepositoryData() { | ||
return in.getRepositoryData(); | ||
} | ||
|
||
@Override | ||
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, MetaData metaData) { | ||
in.initializeSnapshot(snapshotId, indices, metaData); | ||
} | ||
|
||
@Override | ||
public SnapshotInfo finalizeSnapshot(SnapshotId snapshotId, List<IndexId> indices, long startTime, String failure, int totalShards, | ||
List<SnapshotShardFailure> shardFailures, long repositoryStateId, boolean includeGlobalState) { | ||
return in.finalizeSnapshot(snapshotId, indices, startTime, failure, totalShards, shardFailures, repositoryStateId, | ||
includeGlobalState); | ||
} | ||
|
||
@Override | ||
public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId) { | ||
in.deleteSnapshot(snapshotId, repositoryStateId); | ||
} | ||
|
||
@Override | ||
public long getSnapshotThrottleTimeInNanos() { | ||
return in.getSnapshotThrottleTimeInNanos(); | ||
} | ||
|
||
@Override | ||
public long getRestoreThrottleTimeInNanos() { | ||
return in.getRestoreThrottleTimeInNanos(); | ||
} | ||
|
||
@Override | ||
public String startVerification() { | ||
return in.startVerification(); | ||
} | ||
|
||
@Override | ||
public void endVerification(String verificationToken) { | ||
in.endVerification(verificationToken); | ||
} | ||
|
||
@Override | ||
public void verify(String verificationToken, DiscoveryNode localNode) { | ||
in.verify(verificationToken, localNode); | ||
} | ||
|
||
@Override | ||
public boolean isReadOnly() { | ||
return in.isReadOnly(); | ||
} | ||
|
||
@Override | ||
public void snapshotShard(IndexShard shard, Store store, SnapshotId snapshotId, IndexId indexId, IndexCommit snapshotIndexCommit, | ||
IndexShardSnapshotStatus snapshotStatus) { | ||
in.snapshotShard(shard, store, snapshotId, indexId, snapshotIndexCommit, snapshotStatus); | ||
} | ||
|
||
@Override | ||
public void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, IndexId indexId, ShardId snapshotShardId, | ||
RecoveryState recoveryState) { | ||
in.restoreShard(shard, snapshotId, version, indexId, snapshotShardId, recoveryState); | ||
} | ||
|
||
@Override | ||
public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId) { | ||
return in.getShardSnapshotStatus(snapshotId, version, indexId, shardId); | ||
} | ||
|
||
@Override | ||
public void applyPostRestoreOps(IndexShard shard) throws IOException { | ||
in.applyPostRestoreOps(shard); | ||
} | ||
|
||
@Override | ||
public Lifecycle.State lifecycleState() { | ||
return in.lifecycleState(); | ||
} | ||
|
||
@Override | ||
public void addLifecycleListener(LifecycleListener listener) { | ||
in.addLifecycleListener(listener); | ||
} | ||
|
||
@Override | ||
public void removeLifecycleListener(LifecycleListener listener) { | ||
in.removeLifecycleListener(listener); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
in.start(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
in.stop(); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
in.close(); | ||
} | ||
} |
This file contains 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 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 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 |
---|---|---|
|
@@ -846,16 +846,17 @@ private void writeAtomic(final String blobName, final BytesReference bytesRef, b | |
} | ||
|
||
@Override | ||
public void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexId indexId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) { | ||
SnapshotContext snapshotContext = new SnapshotContext(shard, snapshotId, indexId, snapshotStatus, System.currentTimeMillis()); | ||
public void snapshotShard(IndexShard shard, Store store, SnapshotId snapshotId, IndexId indexId, IndexCommit snapshotIndexCommit, | ||
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. do we still need to pass shard in tho this method? 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. yeah unfortunately. I need access to shardPath and the mapper. I can look into this as a follow up |
||
IndexShardSnapshotStatus snapshotStatus) { | ||
SnapshotContext snapshotContext = new SnapshotContext(store, snapshotId, indexId, snapshotStatus, System.currentTimeMillis()); | ||
try { | ||
snapshotContext.snapshot(snapshotIndexCommit); | ||
} catch (Exception e) { | ||
snapshotStatus.moveToFailed(System.currentTimeMillis(), ExceptionsHelper.detailedMessage(e)); | ||
if (e instanceof IndexShardSnapshotFailedException) { | ||
throw (IndexShardSnapshotFailedException) e; | ||
} else { | ||
throw new IndexShardSnapshotFailedException(shard.shardId(), e); | ||
throw new IndexShardSnapshotFailedException(store.shardId(), e); | ||
} | ||
} | ||
} | ||
|
@@ -1158,15 +1159,15 @@ private class SnapshotContext extends Context { | |
/** | ||
* Constructs new context | ||
* | ||
* @param shard shard to be snapshotted | ||
* @param store store to be snapshotted | ||
* @param snapshotId snapshot id | ||
* @param indexId the id of the index being snapshotted | ||
* @param snapshotStatus snapshot status to report progress | ||
*/ | ||
SnapshotContext(IndexShard shard, SnapshotId snapshotId, IndexId indexId, IndexShardSnapshotStatus snapshotStatus, long startTime) { | ||
super(snapshotId, Version.CURRENT, indexId, shard.shardId()); | ||
SnapshotContext(Store store, SnapshotId snapshotId, IndexId indexId, IndexShardSnapshotStatus snapshotStatus, long startTime) { | ||
super(snapshotId, Version.CURRENT, indexId, store.shardId()); | ||
this.snapshotStatus = snapshotStatus; | ||
this.store = shard.store(); | ||
this.store = store; | ||
this.startTime = startTime; | ||
} | ||
|
||
|
This file contains 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 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 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.
@clintongormley @debadair I'd love to get input where this should be linked from and where it should be located. at this point it's stand-alone.