@@ -413,7 +413,7 @@ public static ImmutableOpenMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus>
413413 .entrySet ()) {
414414 SnapshotsInProgress .ShardSnapshotStatus shardStatus = shardSnapshotEntry .getValue ();
415415 ShardId shardId = snapshotEntry .shardId (shardSnapshotEntry .getKey ());
416- if (shardStatus .equals ( SnapshotsInProgress . ShardSnapshotStatus . UNASSIGNED_QUEUED )) {
416+ if (shardStatus .isUnassignedQueued () || shardStatus . isAssignedQueued ( )) {
417417 // this shard snapshot is waiting for a previous snapshot to finish execution for this shard
418418 final SnapshotsInProgress .ShardSnapshotStatus knownFailure = knownFailures .get (shardSnapshotEntry .getKey ());
419419 if (knownFailure == null ) {
@@ -422,14 +422,30 @@ public static ImmutableOpenMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus>
422422 // shard became unassigned while queued after a delete or clone operation so we can fail as missing here
423423 assert snapshotEntry .partial ();
424424 snapshotChanged = true ;
425- logger .debug ("failing snapshot of shard [{}] because index got deleted" , shardId );
426- shards .put (shardId , SnapshotsInProgress .ShardSnapshotStatus .MISSING );
427- knownFailures .put (shardSnapshotEntry .getKey (), SnapshotsInProgress .ShardSnapshotStatus .MISSING );
425+ logger .debug ("failing snapshot of shard [{}] with status [{}] because index got deleted" , shardId , shardStatus );
426+ final SnapshotsInProgress .ShardSnapshotStatus newShardStatus = shardStatus .isAssignedQueued ()
427+ ? new SnapshotsInProgress .ShardSnapshotStatus (
428+ shardStatus .nodeId (),
429+ SnapshotsInProgress .ShardState .FAILED ,
430+ shardStatus .generation (),
431+ "shard is deleted"
432+ )
433+ : SnapshotsInProgress .ShardSnapshotStatus .MISSING ;
434+ shards .put (shardId , newShardStatus );
435+ knownFailures .put (shardSnapshotEntry .getKey (), newShardStatus );
428436 } else {
429437 // if no failure is known for the shard we keep waiting
430438 shards .put (shardId , shardStatus );
431439 }
432440 } else {
441+ assert shardStatus .isAssignedQueued () == false
442+ : shardId
443+ + " with status "
444+ + shardStatus
445+ + " has unexpected known failure "
446+ + knownFailure
447+ + " in snapshot entry "
448+ + snapshotEntry ;
433449 // If a failure is known for an execution we waited on for this shard then we fail with the same exception here
434450 // as well
435451 snapshotChanged = true ;
0 commit comments