**Build scan:**
https://gradle-enterprise.elastic.co/s/vvbkwrzc672ea/tests/:x-pack:plugin:snapshot-based-recoveries:internalClusterTest/org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT/testCancelledRecoveryAbortsDownloadPromptly

**Reproduction line:**
```
./gradlew ':x-pack:plugin:snapshot-based-recoveries:internalClusterTest' --tests "org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT.testCancelledRecoveryAbortsDownloadPromptly" -Dtests.seed=DB2B89F27A651CDB -Dtests.locale=is -Dtests.timezone=Asia/Barnaul -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT&tests.test=testCancelledRecoveryAbortsDownloadPromptly

**Failure excerpt:**
```
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=416, name=elasticsearch[node_t0][generic][T#4], state=RUNNABLE, group=TGRP-SnapshotBasedIndexRecoveryIT]

  at __randomizedtesting.SeedInfo.seed([DB2B89F27A651CDB:44A6B186778E6B1E]:0)

  Caused by: java.lang.AssertionError: (No message provided)

    at __randomizedtesting.SeedInfo.seed([DB2B89F27A651CDB]:0)
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertFalse(Assert.java:64)
    at org.junit.Assert.assertFalse(Assert.java:74)
    at org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT$1.beforeRead(SnapshotBasedIndexRecoveryIT.java:705)
    at org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT$1.read(SnapshotBasedIndexRecoveryIT.java:700)
    at org.elasticsearch.index.snapshots.blobstore.SlicedInputStream.read(SlicedInputStream.java:81)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.index.snapshots.blobstore.RateLimitingInputStream.read(RateLimitingInputStream.java:62)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.index.snapshots.blobstore.RateLimitingInputStream.read(RateLimitingInputStream.java:62)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.indices.recovery.RecoveryTarget$1.read(RecoveryTarget.java:600)
    at java.io.FilterInputStream.read(FilterInputStream.java:95)
    at org.elasticsearch.indices.recovery.MultiFileWriter.writeFile(MultiFileWriter.java:103)
    at org.elasticsearch.indices.recovery.RecoveryTarget.restoreFileFromSnapshot(RecoveryTarget.java:590)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$2.handleRequest(PeerRecoveryTargetService.java:141)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$2.handleRequest(PeerRecoveryTargetService.java:138)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$RecoveryRequestHandler.messageReceived(PeerRecoveryTargetService.java:571)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$RecoveryRequestHandler.messageReceived(PeerRecoveryTargetService.java:558)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:74)
    at org.elasticsearch.transport.InboundHandler$1.doRun(InboundHandler.java:315)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.lang.Thread.run(Thread.java:1623)

```
x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java
(handler, request, channel, task) -> {
                            channelRef.compareAndExchange(null, channel);
                            cleanFilesRequestReceived.countDown();
                        }
                    );
                    respondToRecoverSnapshotFile.run();
                    cleanFilesRequestReceived.await();
                    targetMockTransportService.clearAllRules();
                    channelRef.get().sendResponse(new IOException("unable to clean files"));
                    PeerRecoveryTargetService peerRecoveryTargetService = internalCluster().getInstance(
                        PeerRecoveryTargetService.class,
                        targetNode
                    );
                    assertBusy(() -> {
                        
                        try (Releasable snapshotDownloadPermit = peerRecoveryTargetService.tryAcquireSnapshotDownloadPermits()) {
                            assertThat(snapshotDownloadPermit, is(notNullValue()));
                        }
                    });
                }
                String indexRecoveredFromSnapshot2 = indices.get(1);
                updateIndexSettings(
                    Settings.builder().put("index.routing.allocation.require._name", targetNode),
                    indexRecoveredFromSnapshot2
                );
                ensureGreen(indexRecoveredFromSnapshot2);
                assertPeerRecoveryUsedSnapshots(indexRecoveredFromSnapshot2, sourceNode, targetNode);
            }
        );
    }