Multithreading issue : data from one thread passed on to other thread

Hi,
We are facing this inconsistent issue of data clashing across threads, on production environment of our multiple customer’s. It’s not reproducible at will at all.

Use case : Multiple records (ranging 25-50), with about 30-50 mergeable fields, are processed in parallel across those many threads, to create a PDF out of Word template, using Aspose words 15.11.

At times, the value of a field from 1 thread is getting attached to value of SAME field in thread 2.

Since this happening is not consistent, we tried to capture data at various points to narrow down the root cause.
And every time the data looks to be altered upon performing the Document.save() on aspose library.

Here is the code snippet we use.
(’**** CAPTURED ***’ before and after doc.SAVE(), to assess the discrepancy in printed out vs input XML)

Document doc = new Document(templateFile);

MailMerge merge = doc.getMailMerge();

// Reading the data from xml file for the mail merge
DataSet dataSet = new DataSet();
dataSet.readXml(xmlFilepath);

// ****** CAPTURED XML above *****//

// merge the header fields
DataTableCollection tables = dataSet.getTables();
if (tables != null && tables.getCount() > 0)
{
    merge.execute(tables.get("PrintForm"));
}
// document cleanup settings
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS);
// merge doc table fields
merge.executeWithRegions(dataSet);

// Remove unused regions
//removeUnusedRegions ( doc,new EmptyRegionsHandler()) ;

doc.updateFields();

removeBlankRows(doc);


doc.getFieldOptions().setBarcodeGenerator(new BarcodeGenerator());


doc.setFontSettings(new FontSettings()); //RSTK-14775
doc.getFontSettings().setFontsSources(new FontSourceBase[] { new FolderFontSource(".fonts/", true) });
doc.setWarningCallback(new FontSubstitutionWarningCollector());

com.aspose.words.PdfSaveOptions saveOption = new com.aspose.words.PdfSaveOptions();
com.aspose.words.DownsampleOptions downSampleOption = new DownsampleOptions();
downSampleOption.setDownsampleImages(false);
saveOption.setDownsampleOptions(downSampleOption);

doc.updateFields();
//Saving document as pdf
doc.save(outputDocumentName, saveOption);

// ****** CAPTURED output here from doc.getText() *****//

Do let us know, if such issue has already been attended in higher or latest version of Aspose Words.

This is really CRITICAL for us and our customers, as data in PDF reports is getting altered here.

Regards

@rootforms Unfortunately, I cannot reproduce such problem on my side. It looks like you are using a very old version of Aspose.Words. The latest version is 23.9 version. Please try using it, if the problem still persist, please provide a simple project and documents that will allow us to reproduce the problem. We will check the issue and provide you more information.
In general, Aspose.Words is multithread safe as long as only one thread works on a document at a time. This is a typical scenario to have one thread working on one document. Different threads can safely work on different documents at the same time.
Also, please make sure the data passed to Aspose.Words is also multithread safe.

Thanks @alexey.noskov for quick response.
I understand it’s difficult to reproduce, as we ourselves are not able to do it so far.
We have ensured that per thread there is only one instance of Document. And that has been working over 6 yrs, except these intermittent problems.

Regarding the upgrade, could you let us know if upgraded version has any known changes/fixes related to performance/multi-threading/reflections based implementation etc., so that we can plan to upgrade the library at earliest.

@rootforms New versions of Aspose.Words are released monthly. Since 15.11 version there were 94 new versions of Aspose.Words released. Each version has about 50-60 fixes ad improvements in it. So there were resolved about 5k issues.
You can find lists of the fixed issues and implemented improvements in our release notes:
https://docs.aspose.com/words/java/aspose-words-for-java/

We always encourage our customers to use most recent version of Aspose.Words, since we do not provide fixes for old versions. All fixes are provided with new versions of Aspose.Words.

Got it @alexey.noskov. Thanks!

1 Like