Fix Master Failover and DataNode Leave Blocking Snapshot (#38460)

* Closes #38447
This commit is contained in:
Armin Braun 2019-02-05 23:56:59 +01:00 committed by GitHub
parent 79a45b47da
commit 34f2cc78f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -687,8 +687,9 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
if (event.localNodeMaster()) { if (event.localNodeMaster()) {
// We don't remove old master when master flips anymore. So, we need to check for change in master // We don't remove old master when master flips anymore. So, we need to check for change in master
final SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE); final SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE);
final boolean newMaster = event.previousState().nodes().isLocalNodeElectedMaster() == false;
if (snapshotsInProgress != null) { if (snapshotsInProgress != null) {
if (removedNodesCleanupNeeded(snapshotsInProgress, event.nodesDelta().removedNodes())) { if (newMaster || removedNodesCleanupNeeded(snapshotsInProgress, event.nodesDelta().removedNodes())) {
processSnapshotsOnRemovedNodes(); processSnapshotsOnRemovedNodes();
} }
if (event.routingTableChanged() && waitingShardsStartedOrUnassigned(snapshotsInProgress, event)) { if (event.routingTableChanged() && waitingShardsStartedOrUnassigned(snapshotsInProgress, event)) {
@ -704,7 +705,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|| entry.state() != State.INIT && completed(entry.shards().values()) || entry.state() != State.INIT && completed(entry.shards().values())
).forEach(this::endSnapshot); ).forEach(this::endSnapshot);
} }
if (event.previousState().nodes().isLocalNodeElectedMaster() == false) { if (newMaster) {
finalizeSnapshotDeletionFromPreviousMaster(event); finalizeSnapshotDeletionFromPreviousMaster(event);
} }
} }