Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add stats for remote publication failure and move download failure stats to remote methods([#16682](https://github.com/opensearch-project/OpenSearch/pull/16682/))
- Added a precaution to handle extreme date values during sorting to prevent `arithmetic_exception: long overflow` ([#16812](https://github.com/opensearch-project/OpenSearch/pull/16812)).
- Add search replica stats to segment replication stats API ([#16678](https://github.com/opensearch-project/OpenSearch/pull/16678))
- Introduce a setting to disable download of full cluster state from remote on term mismatch([#16798](https://github.com/opensearch-project/OpenSearch/pull/16798/))

### Dependencies
- Bump `com.google.cloud:google-cloud-core-http` from 2.23.0 to 2.47.0 ([#16504](https://github.com/opensearch-project/OpenSearch/pull/16504))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private GetTermVersionResponse buildResponse(GetTermVersionRequest request, Clus
ClusterStateTermVersion termVersion = new ClusterStateTermVersion(state);
if (discovery instanceof Coordinator) {
Coordinator coordinator = (Coordinator) discovery;
if (coordinator.isRemotePublicationEnabled()) {
if (coordinator.canDownloadFullStateFromRemote()) {
return new GetTermVersionResponse(termVersion, coordinator.isRemotePublicationEnabled());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,4 +1906,12 @@ public boolean isRemotePublicationEnabled() {
}
return false;
}

public boolean canDownloadFullStateFromRemote() {
if (remoteClusterStateService != null) {
return remoteClusterStateService.isRemotePublicationEnabled() && remoteClusterStateService.canDownloadFromRemoteForReadAPI();
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ public void apply(Settings value, Settings current, Settings previous) {
RemoteClusterStateCleanupManager.REMOTE_CLUSTER_STATE_CLEANUP_INTERVAL_SETTING,
RemoteClusterStateService.REMOTE_CLUSTER_STATE_ENABLED_SETTING,
RemoteClusterStateService.REMOTE_PUBLICATION_SETTING,
RemoteClusterStateService.REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API,

INDEX_METADATA_UPLOAD_TIMEOUT_SETTING,
GLOBAL_METADATA_UPLOAD_TIMEOUT_SETTING,
METADATA_MANIFEST_UPLOAD_TIMEOUT_SETTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public class RemoteClusterStateService implements Closeable {
* Gates the functionality of remote publication.
*/
public static final String REMOTE_PUBLICATION_SETTING_KEY = "cluster.remote_store.publication.enabled";
public static final String REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API_KEY = "cluster.remote_state.download.serve_read_api.enabled";

public static final Setting<Boolean> REMOTE_PUBLICATION_SETTING = Setting.boolSetting(
REMOTE_PUBLICATION_SETTING_KEY,
Expand All @@ -137,6 +138,13 @@ public class RemoteClusterStateService implements Closeable {
Property.Dynamic
);

public static final Setting<Boolean> REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API = Setting.boolSetting(
REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API_KEY,
true,
Property.NodeScope,
Property.Dynamic
);

/**
* Used to specify if cluster state metadata should be published to remote store
*/
Expand Down Expand Up @@ -235,6 +243,9 @@ public static RemoteClusterStateValidationMode parseString(String mode) {
+ "indices, coordination metadata updated : [{}], settings metadata updated : [{}], templates metadata "
+ "updated : [{}], custom metadata updated : [{}], indices routing updated : [{}]";
private volatile AtomicBoolean isPublicationEnabled;

private volatile AtomicBoolean downloadFromRemoteForReadAPI;

private final String remotePathPrefix;

private final RemoteClusterStateCache remoteClusterStateCache;
Expand Down Expand Up @@ -281,6 +292,8 @@ public RemoteClusterStateService(
&& RemoteStoreNodeAttribute.isRemoteRoutingTableConfigured(settings)
);
clusterSettings.addSettingsUpdateConsumer(REMOTE_PUBLICATION_SETTING, this::setRemotePublicationSetting);
this.downloadFromRemoteForReadAPI = new AtomicBoolean(clusterSettings.get(REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API));
clusterSettings.addSettingsUpdateConsumer(REMOTE_STATE_DOWNLOAD_TO_SERVE_READ_API, this::setRemoteDownloadForReadAPISetting);
this.remotePathPrefix = CLUSTER_REMOTE_STORE_STATE_PATH_PREFIX.get(settings);
this.remoteRoutingTableService = RemoteRoutingTableServiceFactory.getService(
repositoriesService,
Expand Down Expand Up @@ -1124,6 +1137,14 @@ private void setRemotePublicationSetting(boolean remotePublicationSetting) {
}
}

private void setRemoteDownloadForReadAPISetting(boolean remoteDownloadForReadAPISetting) {
this.downloadFromRemoteForReadAPI.set(remoteDownloadForReadAPISetting);
}

public boolean canDownloadFromRemoteForReadAPI() {
return this.downloadFromRemoteForReadAPI.get();
}

// Package private for unit test
RemoteRoutingTableService getRemoteRoutingTableService() {
return this.remoteRoutingTableService;
Expand Down