Skip to content

Commit

Permalink
Override local disk state if we are able to restore from remote
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Oct 19, 2023
1 parent 69f6f4e commit 1bbd7df
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ public void start(
try {
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))
.version(lastAcceptedVersion)
.metadata(metadata)
.build();

boolean isRemoteStateRestored = false;
if (DiscoveryNode.isClusterManagerNode(settings) && isRemoteStoreClusterStateEnabled(settings)) {
String lastKnownClusterUUID = ClusterState.UNKNOWN_UUID;
// If the cluster UUID loaded from local is unknown (_na_) then fetch the best state from remote
// If there is no valid state on remote, continue with initial empty state
// If there is a valid state, then restore index metadata using this state
String lastKnownClusterUUID = ClusterState.UNKNOWN_UUID;
if (ClusterState.UNKNOWN_UUID.equals(clusterState.metadata().clusterUUID())) {
if (ClusterState.UNKNOWN_UUID.equals(metadata.clusterUUID())) {
lastKnownClusterUUID = remoteClusterStateService.getLastKnownUUIDFromRemote(
clusterState.getClusterName().value()
);
Expand All @@ -181,11 +181,17 @@ public void start(
new String[] {}
);
clusterState = remoteRestoreResult.getClusterState();
isRemoteStateRestored = true;
}
}
remotePersistedState = new RemotePersistedState(remoteClusterStateService, lastKnownClusterUUID);
}

if (isRemoteStateRestored == false) {
// if we did not restore from remote, apply the local disk state.
clusterState = ClusterState.builder(clusterState).metadata(metadata).build();
}

// Recovers Cluster and Index level blocks
clusterState = prepareInitialClusterState(
transportService,
Expand Down

0 comments on commit 1bbd7df

Please sign in to comment.