@@ -228,9 +228,9 @@ private void retry(QueryEvent queryEvent, boolean callFailListeners) {
228
228
runnable .run ();
229
229
}
230
230
/*
231
- * Accepts a QueryBatch which was successfully retrieved from the server and a
232
- * QueryBatchListener which was failed to apply and retry that listener on the batch.
233
- *
231
+ * Accepts a QueryBatch which was successfully retrieved from the server and a
232
+ * QueryBatchListener which was failed to apply and retry that listener on the batch.
233
+ *
234
234
*/
235
235
@ Override
236
236
public void retryListener (QueryBatch batch , QueryBatchListener queryBatchListener ) {
@@ -675,23 +675,22 @@ private class QueryTask implements Runnable {
675
675
private boolean callFailListeners ;
676
676
private String afterUri ;
677
677
private String nextAfterUri ;
678
- boolean isQueryBatch ;
679
678
private QueryBatchImpl batch ;
680
679
private int totalProcessedCount = 0 ;
681
- private boolean isLastBatch ;
682
- private int lastBatchNum ;
683
680
684
681
QueryTask (DataMovementManager moveMgr , QueryBatcherImpl batcher , Forest forest ,
685
682
String queryMethod , SearchQueryDefinition query , Boolean filtered , long forestBatchNum , long start , QueryBatchImpl batch
686
683
) {
687
684
this (moveMgr , batcher , forest , queryMethod , query , filtered , forestBatchNum , start , batch , null , -1 , true );
688
685
}
686
+
689
687
QueryTask (DataMovementManager moveMgr , QueryBatcherImpl batcher , Forest forest ,
690
688
String queryMethod , SearchQueryDefinition query , Boolean filtered , long forestBatchNum , long start , QueryBatchImpl batch , String afterUri
691
689
) {
692
690
this (moveMgr , batcher , forest , queryMethod , query , filtered , forestBatchNum , start , batch , afterUri ,
693
691
-1 , true );
694
692
}
693
+
695
694
QueryTask (DataMovementManager moveMgr , QueryBatcherImpl batcher , Forest forest ,
696
695
String queryMethod , SearchQueryDefinition query , Boolean filtered , long forestBatchNum , long start ,
697
696
QueryBatchImpl batch , String afterUri , long retryBatchNumber , boolean callFailListeners
@@ -704,7 +703,6 @@ private class QueryTask implements Runnable {
704
703
this .filtered = filtered ;
705
704
this .forestBatchNum = forestBatchNum ;
706
705
this .start = start ;
707
- this .isQueryBatch = isQueryBatch ;
708
706
this .retryBatchNumber = retryBatchNumber ;
709
707
this .callFailListeners = callFailListeners ;
710
708
this .batch = batch ;
@@ -745,12 +743,8 @@ public void run() {
745
743
if (consistentSnapshot == true && serverTimestamp .get () > -1 ) {
746
744
handle .setPointInTimeQueryTimestamp (serverTimestamp .get ());
747
745
}
748
- // this try-with-resources block will call results.close() once the block is done
749
- // here we call the /v1/internal/uris endpoint to get the text/uri-list of documents
750
- // matching this structured or string query
746
+
751
747
try (UrisHandle results = queryMgr .uris (queryMethod , query , filtered , handle , start , afterUri , forest .getForestName ())) {
752
- // if we're doing consistentSnapshot and this is the first result set, let's capture the
753
- // serverTimestamp so we can use it for all future queries
754
748
if (consistentSnapshot == true && serverTimestamp .get () == -1 ) {
755
749
if (serverTimestamp .compareAndSet (-1 , results .getServerTimestamp ())) {
756
750
logger .info ("Consistent snapshot timestamp=[{}]" , serverTimestamp );
@@ -785,7 +779,15 @@ public void run() {
785
779
isDone .set (true );
786
780
shutdownIfAllForestsAreDone ();
787
781
return ;
788
- }
782
+ } catch (Throwable t ) {
783
+ // The above catch on a ResourceNotFoundException seems to be an expected error that doesn't need to be
784
+ // logged. But if the query fails for any other reason, such as an invalid index, the error should be
785
+ // logged and the job stopped.
786
+ logger .error ("Query for URIs failed, stopping job; cause: " + t .getMessage (), t );
787
+ isDone .set (true );
788
+ shutdownIfAllForestsAreDone ();
789
+ return ;
790
+ }
789
791
790
792
batch = batch
791
793
.withItems (uris .get (0 ).toArray (new String [uris .get (0 ).size ()]))
@@ -959,7 +961,7 @@ public void run() {
959
961
final List <String > uris = uriQueue ;
960
962
final boolean finalLastBatch = lastBatch ;
961
963
final long results = resultsSoFar .addAndGet (uris .size ());
962
- if (maxUris <= results )
964
+ if (maxUris <= results )
963
965
lastBatch = true ;
964
966
uriQueue = new ArrayList <>(getBatchSize ());
965
967
Runnable processBatch = new Runnable () {
0 commit comments