org.elasticsearch.indices.recovery.RecoveryTarget#restoreFileFromSnapshot does not check for cancellation during the download of a file. This means that if a recovery is cancelled mid-way, we will still not release the store/shard-lock until the file is fully downloaded.
For large files or slow downloads this can lead to problems when the shard is (re-)allocated to a node that is still executing such an interrupted recovery.

-> we need to add some checks for cancellation here like we have for other recovery modes.
server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java
void onRecoveryDone(RecoveryState state, ShardLongFieldRange timestampMillisFieldRange);
        void onRecoveryFailure(RecoveryFailedException e, boolean sendShardFailure);
    }
    class HandoffPrimaryContextRequestHandler implements TransportRequestHandler<RecoveryHandoffPrimaryContextRequest> {
        @Override
        public void messageReceived(final RecoveryHandoffPrimaryContextRequest request, final TransportChannel channel, Task task) {
            final RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId());
            boolean success = false;
            try {
                recoveryRef.target()
                    .handoffPrimaryContext(
                        request.primaryContext(),
                        ActionListener.runBefore(
                            new ChannelActionListener<>(channel).map(v -> TransportResponse.Empty.INSTANCE),
                            recoveryRef::close
                        )
                    );
                success = true;
            } finally {
                if (success == false) {
                    recoveryRef.close();
                }
            }
        }
    }
    private class TranslogOperationsRequestHandler extends RecoveryRequestHandler<RecoveryTranslogOperationsRequest> {