|
73 | 73 | import java.util.Map;
|
74 | 74 | import java.util.concurrent.CountDownLatch;
|
75 | 75 | import java.util.concurrent.TimeUnit;
|
| 76 | +import java.util.concurrent.atomic.AtomicBoolean; |
76 | 77 | import java.util.concurrent.atomic.AtomicInteger;
|
77 | 78 | import java.util.concurrent.atomic.AtomicLong;
|
78 | 79 | import java.util.concurrent.atomic.AtomicReference;
|
@@ -1009,6 +1010,70 @@ public void testRecoveryReEstablishKeepsTheGrantedSnapshotFileDownloadPermit() t
|
1009 | 1010 | });
|
1010 | 1011 | }
|
1011 | 1012 |
|
| 1013 | + public void testRecoveryRetryKeepsTheGrantedSnapshotFileDownloadPermit() throws Exception { |
| 1014 | + executeRecoveryWithSnapshotFileDownloadThrottled((indices, |
| 1015 | + sourceNode, |
| 1016 | + targetNode, |
| 1017 | + targetMockTransportService, |
| 1018 | + recoverySnapshotFileRequests, |
| 1019 | + awaitForRecoverSnapshotFileRequestReceived, |
| 1020 | + respondToRecoverSnapshotFile) -> { |
| 1021 | + MockTransportService sourceMockTransportService = |
| 1022 | + (MockTransportService) internalCluster().getInstance(TransportService.class, sourceNode); |
| 1023 | + |
| 1024 | + CountDownLatch startRecoveryRetryReceived = new CountDownLatch(1); |
| 1025 | + AtomicBoolean delayRecoveryExceptionSent = new AtomicBoolean(); |
| 1026 | + sourceMockTransportService.addRequestHandlingBehavior(PeerRecoverySourceService.Actions.START_RECOVERY, |
| 1027 | + (handler, request, channel, task) -> { |
| 1028 | + if (delayRecoveryExceptionSent.compareAndSet(false, true)) { |
| 1029 | + channel.sendResponse(new DelayRecoveryException("delay")); |
| 1030 | + } else { |
| 1031 | + startRecoveryRetryReceived.countDown(); |
| 1032 | + handler.messageReceived(request, channel, task); |
| 1033 | + } |
| 1034 | + }); |
| 1035 | + |
| 1036 | + String indexRecoveredFromSnapshot1 = indices.get(0); |
| 1037 | + assertAcked( |
| 1038 | + client().admin().indices().prepareUpdateSettings(indexRecoveredFromSnapshot1) |
| 1039 | + .setSettings(Settings.builder() |
| 1040 | + .put("index.routing.allocation.require._name", targetNode)).get() |
| 1041 | + ); |
| 1042 | + |
| 1043 | + startRecoveryRetryReceived.await(); |
| 1044 | + sourceMockTransportService.clearAllRules(); |
| 1045 | + awaitForRecoverSnapshotFileRequestReceived.run(); |
| 1046 | + |
| 1047 | + String indexRecoveredFromPeer = indices.get(1); |
| 1048 | + assertAcked( |
| 1049 | + client().admin().indices().prepareUpdateSettings(indexRecoveredFromPeer) |
| 1050 | + .setSettings(Settings.builder() |
| 1051 | + .put("index.routing.allocation.require._name", targetNode)).get() |
| 1052 | + ); |
| 1053 | + |
| 1054 | + ensureGreen(indexRecoveredFromPeer); |
| 1055 | + assertPeerRecoveryDidNotUseSnapshots(indexRecoveredFromPeer, sourceNode, targetNode); |
| 1056 | + |
| 1057 | + respondToRecoverSnapshotFile.run(); |
| 1058 | + |
| 1059 | + ensureGreen(indexRecoveredFromSnapshot1); |
| 1060 | + assertPeerRecoveryUsedSnapshots(indexRecoveredFromSnapshot1, sourceNode, targetNode); |
| 1061 | + |
| 1062 | + targetMockTransportService.clearAllRules(); |
| 1063 | + |
| 1064 | + final String indexRecoveredFromSnapshot2 = indices.get(2); |
| 1065 | + assertAcked( |
| 1066 | + client().admin().indices().prepareUpdateSettings(indexRecoveredFromSnapshot2) |
| 1067 | + .setSettings(Settings.builder() |
| 1068 | + .put("index.routing.allocation.require._name", targetNode)).get() |
| 1069 | + ); |
| 1070 | + |
| 1071 | + ensureGreen(indexRecoveredFromSnapshot2); |
| 1072 | + assertPeerRecoveryUsedSnapshots(indexRecoveredFromSnapshot2, sourceNode, targetNode); |
| 1073 | + }); |
| 1074 | + } |
| 1075 | + |
| 1076 | + |
1012 | 1077 | private void executeRecoveryWithSnapshotFileDownloadThrottled(SnapshotBasedRecoveryThrottlingTestCase testCase) throws Exception {
|
1013 | 1078 | updateSetting(INDICES_RECOVERY_MAX_CONCURRENT_SNAPSHOT_FILE_DOWNLOADS.getKey(), "1");
|
1014 | 1079 | updateSetting(INDICES_RECOVERY_MAX_CONCURRENT_SNAPSHOT_FILE_DOWNLOADS_PER_NODE.getKey(), "1");
|
|
0 commit comments