diff --git a/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index eba96e15de50c..1528b11773a67 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -229,6 +229,11 @@ private void deleteShardIfExistElseWhere( long clusterStateVersion, IndexShardRoutingTable indexShardRoutingTable ) { + if (DiscoveryNode.isStateless(clusterService.getSettings())) { + deleteShardStoreOnApplierThread(indexShardRoutingTable.shardId(), clusterStateVersion); + return; + } + List> requests = new ArrayList<>(indexShardRoutingTable.size()); String indexUUID = indexShardRoutingTable.shardId().getIndex().getUUID(); for (int copy = 0; copy < indexShardRoutingTable.size(); copy++) { @@ -320,34 +325,37 @@ private void allNodesResponded() { return; } - clusterService.getClusterApplierService() - .runOnApplierThread("indices_store ([" + shardId + "] active fully on other nodes)", Priority.HIGH, currentState -> { - if (clusterStateVersion != currentState.getVersion()) { - logger.trace( - "not deleting shard {}, the update task state version[{}] is not equal to cluster state before " - + "shard active api call [{}]", - shardId, - currentState.getVersion(), - clusterStateVersion - ); - return; - } - try { - indicesService.deleteShardStore("no longer used", shardId, currentState); - } catch (Exception ex) { - logger.debug(() -> format("%s failed to delete unallocated shard, ignoring", shardId), ex); - } - }, new ActionListener<>() { - @Override - public void onResponse(Void unused) {} - - @Override - public void onFailure(Exception e) { - logger.error(() -> format("%s unexpected error during deletion of unallocated shard", shardId), e); - } - }); + deleteShardStoreOnApplierThread(shardId, clusterStateVersion); } + } + private void deleteShardStoreOnApplierThread(ShardId shardId, long clusterStateVersion) { + clusterService.getClusterApplierService() + .runOnApplierThread("indices_store ([" + shardId + "] active fully on other nodes)", Priority.HIGH, currentState -> { + if (clusterStateVersion != currentState.getVersion()) { + logger.trace( + "not deleting shard {}, the update task state version[{}] is not equal to cluster state before " + + "shard active api call [{}]", + shardId, + currentState.getVersion(), + clusterStateVersion + ); + return; + } + try { + indicesService.deleteShardStore("no longer used", shardId, currentState); + } catch (Exception ex) { + logger.debug(() -> format("%s failed to delete unallocated shard, ignoring", shardId), ex); + } + }, new ActionListener<>() { + @Override + public void onResponse(Void unused) {} + + @Override + public void onFailure(Exception e) { + logger.error(() -> format("%s unexpected error during deletion of unallocated shard", shardId), e); + } + }); } private class ShardActiveRequestHandler implements TransportRequestHandler {