@@ -229,6 +229,11 @@ private void deleteShardIfExistElseWhere(
229229 long clusterStateVersion ,
230230 IndexShardRoutingTable indexShardRoutingTable
231231 ) {
232+ if (DiscoveryNode .isStateless (clusterService .getSettings ())) {
233+ deleteShardStoreOnApplierThread (indexShardRoutingTable .shardId (), clusterStateVersion );
234+ return ;
235+ }
236+
232237 List <Tuple <DiscoveryNode , ShardActiveRequest >> requests = new ArrayList <>(indexShardRoutingTable .size ());
233238 String indexUUID = indexShardRoutingTable .shardId ().getIndex ().getUUID ();
234239 for (int copy = 0 ; copy < indexShardRoutingTable .size (); copy ++) {
@@ -320,34 +325,37 @@ private void allNodesResponded() {
320325 return ;
321326 }
322327
323- clusterService .getClusterApplierService ()
324- .runOnApplierThread ("indices_store ([" + shardId + "] active fully on other nodes)" , Priority .HIGH , currentState -> {
325- if (clusterStateVersion != currentState .getVersion ()) {
326- logger .trace (
327- "not deleting shard {}, the update task state version[{}] is not equal to cluster state before "
328- + "shard active api call [{}]" ,
329- shardId ,
330- currentState .getVersion (),
331- clusterStateVersion
332- );
333- return ;
334- }
335- try {
336- indicesService .deleteShardStore ("no longer used" , shardId , currentState );
337- } catch (Exception ex ) {
338- logger .debug (() -> format ("%s failed to delete unallocated shard, ignoring" , shardId ), ex );
339- }
340- }, new ActionListener <>() {
341- @ Override
342- public void onResponse (Void unused ) {}
343-
344- @ Override
345- public void onFailure (Exception e ) {
346- logger .error (() -> format ("%s unexpected error during deletion of unallocated shard" , shardId ), e );
347- }
348- });
328+ deleteShardStoreOnApplierThread (shardId , clusterStateVersion );
349329 }
330+ }
350331
332+ private void deleteShardStoreOnApplierThread (ShardId shardId , long clusterStateVersion ) {
333+ clusterService .getClusterApplierService ()
334+ .runOnApplierThread ("indices_store ([" + shardId + "] active fully on other nodes)" , Priority .HIGH , currentState -> {
335+ if (clusterStateVersion != currentState .getVersion ()) {
336+ logger .trace (
337+ "not deleting shard {}, the update task state version[{}] is not equal to cluster state before "
338+ + "shard active api call [{}]" ,
339+ shardId ,
340+ currentState .getVersion (),
341+ clusterStateVersion
342+ );
343+ return ;
344+ }
345+ try {
346+ indicesService .deleteShardStore ("no longer used" , shardId , currentState );
347+ } catch (Exception ex ) {
348+ logger .debug (() -> format ("%s failed to delete unallocated shard, ignoring" , shardId ), ex );
349+ }
350+ }, new ActionListener <>() {
351+ @ Override
352+ public void onResponse (Void unused ) {}
353+
354+ @ Override
355+ public void onFailure (Exception e ) {
356+ logger .error (() -> format ("%s unexpected error during deletion of unallocated shard" , shardId ), e );
357+ }
358+ });
351359 }
352360
353361 private class ShardActiveRequestHandler implements TransportRequestHandler <ShardActiveRequest > {
0 commit comments