Skip to content

QueryBatcher job fails to stop if underlying query has an error #1287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
georgeajit opened this issue Feb 5, 2021 · 5 comments
Closed

QueryBatcher job fails to stop if underlying query has an error #1287

georgeajit opened this issue Feb 5, 2021 · 5 comments

Comments

@georgeajit
Copy link

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.

@anu3990
Copy link
Contributor

anu3990 commented Jun 25, 2021

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

@ehennum
Copy link
Contributor

ehennum commented Jun 25, 2021

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.

@llinggit
Copy link
Contributor

llinggit commented Jul 2, 2021

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

@rjrudin
Copy link
Contributor

rjrudin commented Nov 17, 2022

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

@rjrudin rjrudin closed this as completed Nov 17, 2022
@rjrudin
Copy link
Contributor

rjrudin commented Nov 17, 2022

Tracked via JAVA-270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants