-
Notifications
You must be signed in to change notification settings - Fork 74
Description
When we run our integration test-suite especially the tests using the DataMovementManager and a QueryBatcher. The LinkedBlockingQueue used in QueryBatcherImpl#QueryThreadPoolExecutor (QueryBatcherImpl line 1132) is throwing an IllegalArgumentException because the poolSize is calculated to be -1. The line in question is QueryBatcherImpl#1132:
new LinkedBlockingQueue<>((forestsLength * docToUriBatchRatio * 2) + threadCount)
with forestsLength=1, docToUriBatchRatio=-1, threadCount=1
It is wierd that docToUriBatchRatio is -1. Having a look at QueryBatcherImpl#withBatchSize (line 296), which is called in our case:
public QueryBatcher withBatchSize(int docBatchSize) {
if (docBatchSize > this.maxUriBatchSize) {
logger.debug("docBatchSize is beyond maxDocBatchSize, which is {}.", this.maxUriBatchSize);
}
if (docBatchSize < 1) {
throw new IllegalArgumentException("docBatchSize cannot be less than 1");
}
requireNotStarted();
super.withBatchSize(docBatchSize);
this.docToUriBatchRatio = Math.min(this.maxDocToUriBatchRatio, this.maxUriBatchSize / docBatchSize);
if (this.docToUriBatchRatio == 0) {
this.docToUriBatchRatio = 1;
}
return this;
}
it happens in line 305 due to maxDocToUriBatchRatio being -1. This -1 is taken from the forest-response given by the MarkLogic server in DataMovementServices#initConfig (line 64). (The else-branch in line 67 is not visited in our case.)
Solutions:
It feels like the maxDocToUriBatchRatio=-1 given by the MarkLogic server is supposed to mean something like "undefined" or "unlimited". Using the -1 in the calculation for the thread pool size seems oddly wrong. If so intended, we would appreciate a proper error message like "QueryBatcher can not be started ...". Currently just an IllegalArgumentException without any message is thrown by the Java's native LinkedBlockingQueue.