@@ -189,6 +189,20 @@ private void trySendingRequestsForPendingShards(TargetShards targetShards, Compu
189189 if (changed .compareAndSet (true , false ) == false ) {
190190 break ;
191191 }
192+ var pendingRetries = new HashSet <ShardId >();
193+ for (ShardId shardId : pendingShardIds ) {
194+ if (targetShards .getShard (shardId ).remainingNodes .isEmpty ()) {
195+ var failure = shardFailures .get (shardId );
196+ if (failure != null && failure .fatal == false && failure .failure instanceof NoShardAvailableActionException ) {
197+ pendingRetries .add (shardId );
198+ }
199+ }
200+ }
201+ if (pendingRetries .isEmpty () == false && remainingUnavailableShardResolutionAttempts .decrementAndGet () >= 0 ) {
202+ for (var entry : resolveShards (pendingRetries ).entrySet ()) {
203+ targetShards .getShard (entry .getKey ()).remainingNodes .addAll (entry .getValue ());
204+ }
205+ }
192206 for (ShardId shardId : pendingShardIds ) {
193207 if (targetShards .getShard (shardId ).remainingNodes .isEmpty ()) {
194208 shardFailures .compute (
@@ -257,26 +271,11 @@ private void sendOneNodeRequest(TargetShards targetShards, ComputeListener compu
257271 final ActionListener <DriverCompletionInfo > listener = computeListener .acquireCompute ();
258272 sendRequest (request .node , request .shardIds , request .aliasFilters , new NodeListener () {
259273
260- private final Set <ShardId > pendingRetries = new HashSet <>();
261-
262274 void onAfter (DriverCompletionInfo info ) {
263275 nodePermits .get (request .node ).release ();
264276 if (concurrentRequests != null ) {
265277 concurrentRequests .release ();
266278 }
267-
268- if (pendingRetries .isEmpty () == false && remainingUnavailableShardResolutionAttempts .decrementAndGet () >= 0 ) {
269- try {
270- sendingLock .lock ();
271- var resolutions = resolveShards (pendingRetries );
272- for (var entry : resolutions .entrySet ()) {
273- targetShards .shards .get (entry .getKey ()).remainingNodes .addAll (entry .getValue ());
274- }
275- } finally {
276- sendingLock .unlock ();
277- }
278- }
279-
280279 trySendingRequestsForPendingShards (targetShards , computeListener );
281280 listener .onResponse (info );
282281 }
@@ -293,7 +292,6 @@ public void onResponse(DataNodeComputeResponse response) {
293292 final ShardId shardId = entry .getKey ();
294293 trackShardLevelFailure (shardId , false , entry .getValue ());
295294 pendingShardIds .add (shardId );
296- maybeScheduleRetry (shardId , false , entry .getValue ());
297295 }
298296 onAfter (response .completionInfo ());
299297 }
@@ -303,7 +301,6 @@ public void onFailure(Exception e, boolean receivedData) {
303301 for (ShardId shardId : request .shardIds ) {
304302 trackShardLevelFailure (shardId , receivedData , e );
305303 pendingShardIds .add (shardId );
306- maybeScheduleRetry (shardId , receivedData , e );
307304 }
308305 onAfter (DriverCompletionInfo .EMPTY );
309306 }
@@ -317,14 +314,6 @@ public void onSkip() {
317314 onResponse (new DataNodeComputeResponse (DriverCompletionInfo .EMPTY , Map .of ()));
318315 }
319316 }
320-
321- private void maybeScheduleRetry (ShardId shardId , boolean receivedData , Exception e ) {
322- if (receivedData == false
323- && targetShards .getShard (shardId ).remainingNodes .isEmpty ()
324- && unwrapFailure (shardId , e ) instanceof NoShardAvailableActionException ) {
325- pendingRetries .add (shardId );
326- }
327- }
328317 });
329318 }
330319
0 commit comments