mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Previously, we could run into a situation where attempting to delete an index due to a cluster state update would cause an unhandled exception to bubble up to the ClusterService and cause the cluster state applier to fail. The result of this situation is that the cluster state never gets updated on the ClusterService because the exception happens before all cluster state appliers have completed and the ClusterService only updates the cluster state once all cluster state appliers have successfully completed. All other methods on IndicesService properly handle all exceptions and not just IOExceptions, but there were two instances with respect to index deletion where only IOExceptions where handled by the IndicesService. If any other exception occurred during these delete operations, the exception would be bubbled up to the ClusterService, causing the aforementioned issues. This commit ensures all methods in IndicesService properly capture all types of Exceptions, so that the ClusterService manages to update the cluster state, even in the presence of shard creation/deletion failures. Note that the lack of updating the cluster state in the presence of such exceptions can have many unintended consequences, one of them being the tripping of the assertion in IndicesClusterStateService#removeUnallocatedIndices where the assumption is that if there is an IndexService to remove with an unassigned shard, then the index must exist in the cluster state, but if the cluster state was never updated due to the aforementioned exceptions, then the cluster state will not have the index in question.