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 56736be commit 1d9a06d
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ public void start(
try {
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))
.version(lastAcceptedVersion)
.metadata(metadata)
.build();

// 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
boolean isRemoteStateRestored = false;
if (DiscoveryNode.isClusterManagerNode(settings) && isRemoteStoreClusterStateEnabled(settings)) {
// 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())) {
lastKnownClusterUUID = remoteClusterStateService.getLastKnownUUIDFromRemote(
Expand All @@ -178,9 +178,10 @@ public void start(
clusterState,
lastKnownClusterUUID,
false,
new String[] {}
new String[]{}
);
clusterState = remoteRestoreResult.getClusterState();
isRemoteStateRestored = true;
}
}
remotePersistedState = new RemotePersistedState(remoteClusterStateService, lastKnownClusterUUID);
Expand All @@ -190,7 +191,8 @@ public void start(
clusterState = prepareInitialClusterState(
transportService,
clusterService,
ClusterState.builder(clusterState)
// if we did not restore from remote, apply the local disk state.
ClusterState.builder(isRemoteStateRestored ? clusterState : ClusterState.builder(clusterState).metadata(metadata).build())
.metadata(upgradeMetadataForNode(clusterState.metadata(), metadataIndexUpgradeService, metadataUpgrader))
.build()
);
Expand Down

0 comments on commit 1d9a06d

Please sign in to comment.