java-client-api icon indicating copy to clipboard operation
java-client-api copied to clipboard

QueryBatcher job fails to stop if underlying query has an error

Open georgeajit opened this issue 4 years ago • 3 comments

So we can address your issue, please include the following:

Version of MarkLogic Java Client API

develop (after 5.3.2 tag release)

Version of MarkLogic Server

10.0-6

Java version

JDK 1.8 u 261

OS and version

Windows with IntelliJ IDE

Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end

Having a QueryDefinition with incorrect query details (though syntax is appropriate) and running a QueryBatcher job causes the job to hang indefinitely.

In example below we have all setups done correcly on server, as far as path namespaces, path range indices are concerned. Yet on client side, query is incorrect due to wrong namespace settings.

	  StructuredQueryBuilder queryBuilder = queryManager.newStructuredQueryBuilder();
      EditableNamespaceContext namespaceContext = new EditableNamespaceContext();
      namespaceContext.put("nsdate", "Wrong URI");
      namespaceContext.put("ns1", "Wrong URI");
      namespaceContext.put("ns2", "Wrong URI");
      queryBuilder.setNamespaces(namespaceContext);

      StructuredQueryDefinition qd = queryBuilder.range(
              queryBuilder.pathIndex("//nsdate:date"),
              "xs:date", StructuredQueryBuilder.Operator.GT, "2007-01-01");

      QueryBatcher qb = dmManager.newQueryBatcher(qd)
              .onUrisReady(batch -> {
                System.out.println("Items: " + Arrays.asList(batch.getItems()));
                for(String s:batch.getItems()) {
                  resultUris.append(s);
                  resultUris.append("|");
                  docCnt.incrementAndGet();
                }
              })
              .onQueryFailure(failure -> {
                System.out.println("Failure: " + failure.getMessage());
                failStr.append(failure.getMessage());
              });
      try {
        dmManager.startJob(qb);
        qb.awaitCompletion();
      } catch (Exception e) {
        System.out.println("Exceptions thrown from Query Batcher job");
      }
      finally {
        dmManager.stopJob(qb);
		
	}

Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)

Exception in thread "pool-3-thread-1" com.marklogic.client.FailedRequestException: Local message: failed to apply resource at internal/uris: Bad Request. Server Message: XDMP-PATHRIDXNOTFOUND: cts:register(cts:path-range-query("//nsdate:date", ">", xs:date("2007-01-01"), (), 1)) -- No date path range index for //nsdate:date  
	at com.marklogic.client.impl.OkHttpServices.checkStatus(OkHttpServices.java:4449)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3438)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3382)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3373)
	at com.marklogic.client.impl.OkHttpServices.processQuery(OkHttpServices.java:3130)
	at com.marklogic.client.impl.OkHttpServices.uris(OkHttpServices.java:3030)
	at com.marklogic.client.impl.QueryManagerImpl.uris(QueryManagerImpl.java:169)
	at com.marklogic.client.datamovement.impl.QueryBatcherImpl$QueryTask.run(QueryBatcherImpl.java:759)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.base/java.lang.Thread.run(Thread.java:844)

The job will not finish and hangs indefinitely.

Expected output: What specifically did you expect to happen?

Doc uris to be returned, based on query criteria.

Alternatives: What else have you tried, actual/expected?

None.

georgeajit avatar Feb 05 '21 22:02 georgeajit

This issue needs work in the REST side. The REST api needs to verify statically that the query matches the database configuration.

anu3990 avatar Jun 25 '21 19:06 anu3990

In particular, the internal endpoint called during initialization of the query batcher should tell the client to throw an error if the query is invalid.

ehennum avatar Jun 25 '21 19:06 ehennum

According to @ehennum , as this issue includes server side work, we'll move this issue along with 10.0-8 server release.

llinggit avatar Jul 02 '21 21:07 llinggit

Verified this is still an issue, will track in JIRA.

rjrudin avatar Nov 17 '22 17:11 rjrudin

Tracked via JAVA-270

rjrudin avatar Nov 17 '22 17:11 rjrudin