Skip to content

Commit

Permalink
Fix Leaking Listener in BlobStoreRepository (#69110) (#69559)
Browse files Browse the repository at this point in the history
We have no guarantees that implementations won't throw a non-IO exception in this spot
so we have to make sure to resolve the listener on any exception to not leak it.
  • Loading branch information
original-brownbear committed Feb 24, 2021
1 parent f2f432d commit b01f80b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ private void initializeRepoGenerationTracking(ActionListener<RepositoryData> lis
}
existingListener.onFailure(e);
};
threadPool.generic().execute(() -> doGetRepositoryData(
threadPool.generic().execute(ActionRunnable.wrap(
ActionListener.wrap(repoData -> clusterService.submitStateUpdateTask(
"set safe repository generation [" + metadata.name() + "][" + repoData + "]",
new ClusterStateUpdateTask() {
Expand Down Expand Up @@ -1410,7 +1410,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
existingListener.onResponse(repoData);
});
}
}), onFailure)));
}), onFailure), this::doGetRepositoryData));
} else {
logger.trace("[{}] waiting for existing initialization of repository metadata generation in cluster state",
metadata.name());
Expand All @@ -1432,9 +1432,9 @@ private void doGetRepositoryData(ActionListener<RepositoryData> listener) {
final long generation;
try {
generation = latestIndexBlobId();
} catch (IOException ioe) {
} catch (Exception e) {
listener.onFailure(
new RepositoryException(metadata.name(), "Could not determine repository generation from root blobs", ioe));
new RepositoryException(metadata.name(), "Could not determine repository generation from root blobs", e));
return;
}
genToLoad = latestKnownRepoGen.updateAndGet(known -> Math.max(known, generation));
Expand Down

0 comments on commit b01f80b

Please sign in to comment.