marklogic/java-client-api

QueryBatcher hangs if batchSize is not specified

srinathgit opened this issue · 4 comments

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

Version of MarkLogic Java Client API

See Readme.txt
5.4.0

Version of MarkLogic Server

9.0-12
See admin gui on port 8001 or run xdmp:version() in Query Console - port 8000)

Java version

8
Run java -version

OS and version

For MAC, run sw_vers.
For Windows, run systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
For Linux, run cat /etc/os-release and uname -r

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

            DataMovementManager dmm = client.newDataMovementManager();
            QueryBatcher queryBatcher = dmm.newQueryBatcher(new StructuredQueryBuilder().collection("collA"))
                //.withBatchSize(100)
                .withThreadCount(1);
            dmm.startJob(queryBatcher);
            queryBatcher.awaitCompletion();
            dmm.stopJob(queryBatcher);

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

When we run the above snippet, the following exception is thrown and QB hangs.

Exception in thread "pool-1-thread-1" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
	at java.util.ArrayList.get(ArrayList.java:433)
	at com.marklogic.client.datamovement.impl.QueryBatcherImpl$QueryTask.run(QueryBatcherImpl.java:775)

Expected output: What specifically did you expect to happen?

Expect QB to return the uris and not hang.

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

Once the batch size is set (uncomment withBatchSize(100) from the snippet), it runs fine. Looks like 'docToUriBatchRatio' becomes zero if batch size is not set.

Hi Anu, I think this is happening because we don't get server side metrics in 9.0. We get below metrics in 10 and trunk.
queryConfig.maxDocToUriBatchRatio, queryConfig.defaultDocBatchSize, queryConfig.maxUriBatchSize);

We can either fix on server side to get these values. Or we can fix on client side. Which one do you think is better?

Hi @srinathgit, we could not recreate the error with the current develop branch and 9.0-12 server. Can you please check from your end and update us? (Please test with the develop branch of java-client-api)

Heard from @georgeajit that we only tested Java Client API 4.2 against MarkLogic 9.0 server. All Java Client API 5.x releases are only tested against 10.0. Should we continue working on this issue?

Some background (if I understand correctly)...

If the customer can solve the problem by upgrading to the latest server release on the same server branch, we would rarely if ever add code to an older server release. (Why cut a point release, given that they have to upgrade either way?)

We could add code to the client that solves the problem for an older server release but would typically do that only if the problem is an unavoidable problem for many customers.