Skip to content

Commit 38168a6

Browse files
Fix Edge-Case Threading Bug in TransportMountSearchableSnapshotAction
The callback to loading the repository-data may not run on generic in the uncached case because of the repo data deduplication logic. The same issue was fixed for the snapshot status API in #68023
1 parent d5bf72a commit 38168a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/TransportMountSearchableSnapshotAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.elasticsearch.ElasticsearchException;
1111
import org.elasticsearch.Version;
1212
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.StepListener;
1413
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
1514
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
1615
import org.elasticsearch.action.support.ActionFilters;
@@ -26,6 +25,7 @@
2625
import org.elasticsearch.common.inject.Inject;
2726
import org.elasticsearch.common.settings.Setting;
2827
import org.elasticsearch.common.settings.Settings;
28+
import org.elasticsearch.common.util.concurrent.ListenableFuture;
2929
import org.elasticsearch.index.IndexNotFoundException;
3030
import org.elasticsearch.indices.ShardLimitValidator;
3131
import org.elasticsearch.indices.SystemIndices;
@@ -185,9 +185,9 @@ protected void masterOperation(
185185
final Repository repository = repositoriesService.repository(repoName);
186186
SearchableSnapshots.getSearchableRepository(repository); // just check it's valid
187187

188-
final StepListener<RepositoryData> repositoryDataListener = new StepListener<>();
188+
final ListenableFuture<RepositoryData> repositoryDataListener = new ListenableFuture<>();
189189
repository.getRepositoryData(repositoryDataListener);
190-
repositoryDataListener.whenComplete(repoData -> {
190+
repositoryDataListener.addListener(ActionListener.wrap(repoData -> {
191191
final Map<String, IndexId> indexIds = repoData.getIndices();
192192
if (indexIds.containsKey(indexName) == false) {
193193
throw new IndexNotFoundException("index [" + indexName + "] not found in repository [" + repoName + "]");
@@ -280,6 +280,6 @@ protected void masterOperation(
280280
.snapshotUuid(snapshotId.getUUID()),
281281
listener
282282
);
283-
}, listener::onFailure);
283+
}, listener::onFailure), threadPool.generic(), null);
284284
}
285285
}

0 commit comments

Comments
 (0)