marklogic/java-client-api

WriteBatcher does not write documents when total documents provided is less than 100 and without using withBatchSize

anu3990 opened this issue · 1 comments

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

Version of MarkLogic Java Client API

See Readme.txt

Version of MarkLogic Server

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

Java version

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 moveMgr = Common.client.newDataMovementManager();
WriteBatcher writeBatcher = moveMgr.newWriteBatcher();
DocumentMetadataHandle meta = new DocumentMetadataHandle().withCollections("RowManagerValidateDocTest");
moveMgr.startJob(writeBatcher);
for(int i=0; i<99; i++){
writeBatcher.addAs("test"+i, meta, new StringHandle(""+i+"value"+i+"").withFormat(XML));
}
writeBatcher.awaitCompletion();
moveMgr.stopJob(writeBatcher);

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

No documents were written to the database

Expected output: What specifically did you expect to happen? 99 documents should be written to the database.

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

If the total number of documents was >= 100, all the documents were written. Also, when we use withhBatchSize, all the documents were written. For example, all the 99 documents were written to the database -

DataMovementManager moveMgr = Common.client.newDataMovementManager();
WriteBatcher writeBatcher = moveMgr.newWriteBatcher().withBatchSize(99);
DocumentMetadataHandle meta = new DocumentMetadataHandle().withCollections("RowManagerValidateDocTest");
moveMgr.startJob(writeBatcher);
for(int i=0; i<99; i++){
writeBatcher.addAs(DIRECTORY+i, meta, new StringHandle(""+i+"value"+i+"").withFormat(XML));
}
writeBatcher.awaitCompletion();
moveMgr.stopJob(writeBatcher);

We can use flushAndWait instead of awaitCompletion.