-
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
SNAPSHOTS: Allow Parallel Restore Operations #36397
Changes from 1 commit
8e903ec
cee0adf
7ceb2b6
9d18495
7411054
f114c97
c0286da
d3cc957
8076986
f12d1fb
d510c78
87d3bf3
1de0350
b9e3a05
2a8573d
3c6cd85
d4e19f5
ff0596d
389ceee
7731a9d
183ded2
144aa26
808eac4
5c26af3
70e29d0
615bd69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,11 +223,13 @@ public void restoreSnapshot(final RestoreRequest request, final ActionListener<R | |
|
||
@Override | ||
public ClusterState execute(ClusterState currentState) { | ||
// Check if another restore process is already running - cannot run two restore processes at the | ||
// same time | ||
RestoreInProgress restoreInProgress = currentState.custom(RestoreInProgress.TYPE); | ||
if (restoreInProgress != null && !restoreInProgress.entries().isEmpty()) { | ||
throw new ConcurrentSnapshotExecutionException(snapshot, "Restore process is already running in this cluster"); | ||
if (currentState.getNodes().getMinNodeVersion().before(Version.V_7_0_0)) { | ||
// Check if another restore process is already running - cannot run two restore processes at the | ||
// same time in versions prior to 7.0 | ||
if (restoreInProgress != null && !restoreInProgress.entries().isEmpty()) { | ||
throw new ConcurrentSnapshotExecutionException(snapshot, "Restore process is already running in this cluster"); | ||
} | ||
} | ||
// Check if the snapshot to restore is currently being deleted | ||
SnapshotDeletionsInProgress deletionsInProgress = currentState.custom(SnapshotDeletionsInProgress.TYPE); | ||
|
@@ -330,7 +332,14 @@ public ClusterState execute(ClusterState currentState) { | |
|
||
shards = shardsBuilder.build(); | ||
RestoreInProgress.Entry restoreEntry = new RestoreInProgress.Entry(snapshot, overallState(RestoreInProgress.State.INIT, shards), Collections.unmodifiableList(new ArrayList<>(indices.keySet())), shards); | ||
builder.putCustom(RestoreInProgress.TYPE, new RestoreInProgress(restoreEntry)); | ||
List<RestoreInProgress.Entry> newEntries; | ||
original-brownbear marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (restoreInProgress != null) { | ||
newEntries = new ArrayList<>(restoreInProgress.entries()); | ||
} else { | ||
newEntries = new ArrayList<>(1); | ||
} | ||
newEntries.add(restoreEntry); | ||
builder.putCustom(RestoreInProgress.TYPE, new RestoreInProgress(newEntries.toArray(new RestoreInProgress.Entry[0]))); | ||
} else { | ||
shards = ImmutableOpenMap.of(); | ||
} | ||
|
@@ -617,7 +626,7 @@ public RestoreInProgress applyChanges(final RestoreInProgress oldRestore) { | |
for (RestoreInProgress.Entry entry : oldRestore.entries()) { | ||
Snapshot snapshot = entry.snapshot(); | ||
Updates updates = shardChanges.get(snapshot); | ||
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. also key the shardChanges by restore UUID? |
||
if (updates.shards.isEmpty() == false) { | ||
if (updates != null && updates.shards.isEmpty() == false) { | ||
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. Now having an update here doesn't necessarily mean an update for every snapshot so we need the |
||
ImmutableOpenMap.Builder<ShardId, ShardRestoreStatus> shardsBuilder = ImmutableOpenMap.builder(entry.shards()); | ||
for (Map.Entry<ShardId, ShardRestoreStatus> shard : updates.shards.entrySet()) { | ||
shardsBuilder.put(shard.getKey(), shard.getValue()); | ||
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 this should now only be updated if the previous entry is not completed 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. Added that check now :) 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 meant that if the respective |
||
|
@@ -630,7 +639,7 @@ public RestoreInProgress applyChanges(final RestoreInProgress oldRestore) { | |
entries.add(entry); | ||
} | ||
} | ||
return new RestoreInProgress(entries.toArray(new RestoreInProgress.Entry[entries.size()])); | ||
return new RestoreInProgress(entries.toArray(new RestoreInProgress.Entry[0])); | ||
} else { | ||
return oldRestore; | ||
} | ||
|
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.
Here we did assume only a single restore in parallel previously, now we have to add
restoreEntry
to the existing list if it's there.