mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
[Discovery] lightweight minimum master node recovery
don't perform full recovery when minimum master nodes are not met, keep the state around and use it once elected as master
This commit is contained in:
parent
5453c08f50
commit
63d0406b67
@ -846,24 +846,16 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||
|
||||
ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks())
|
||||
.addGlobalBlock(NO_MASTER_BLOCK)
|
||||
.addGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)
|
||||
.build();
|
||||
|
||||
// clear the routing table, we have no master, so we need to recreate the routing when we reform the cluster
|
||||
RoutingTable routingTable = RoutingTable.builder().build();
|
||||
// we also clean the metadata, since we are going to recover it if we become master
|
||||
MetaData metaData = MetaData.builder().build();
|
||||
|
||||
// clean the nodes, we are now not connected to anybody, since we try and reform the cluster
|
||||
latestDiscoNodes = new DiscoveryNodes.Builder().put(localNode).localNodeId(localNode.id()).build();
|
||||
latestDiscoNodes = new DiscoveryNodes.Builder(latestDiscoNodes).masterNodeId(null).build();
|
||||
|
||||
asyncJoinCluster();
|
||||
|
||||
return ClusterState.builder(clusterState)
|
||||
.blocks(clusterBlocks)
|
||||
.nodes(latestDiscoNodes)
|
||||
.routingTable(routingTable)
|
||||
.metaData(metaData)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -134,12 +134,6 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
||||
if (lifecycle.stoppedOrClosed()) {
|
||||
return;
|
||||
}
|
||||
if (event.state().blocks().hasGlobalBlock(Discovery.NO_MASTER_BLOCK)) {
|
||||
// we need to clear those flags, since we might need to recover again in case we disconnect
|
||||
// from the cluster and then reconnect
|
||||
recovered.set(false);
|
||||
scheduledRecovery.set(false);
|
||||
}
|
||||
if (event.localNodeMaster() && event.state().blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK)) {
|
||||
checkStateMeetsSettingsAndMaybeRecover(event.state(), true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user