my program crashed without any execption.
I'm running multiple queries from mutiple threads to simualte a scenaio seen in production environment and got his crash 3 times.
I've 9 threads running where 5 threads are reading one XML entry in one document and 1 thread is adding entry into smae document and 2 threads trying to delete the XML entries from the same document. The last thread is reading metadata.

3 crashes with same crash signature seen in reading thread. Below is the code which does perform query:

my program crashed without any execption.
I'm running multiple queries from mutiple threads to simualte a scenaio seen in production environment and got his crash 3 times.
I've 9 threads running where 5 threads are reading one XML entry in one document and 1 thread is adding entry into smae document and 2 threads trying to delete the XML entries from the same document. The last thread is reading metadata.

3 crashes with same crash signature seen in reading thread. Below is the code which does perform query:

I'd say that, given that it's still difficult to tell what exactly the issue is, there probably isn't a fix for it, or at least not one that comes to mind immediately. It looks like you're reaching the upper limits of what you can achieve with that many threads reading, writing and updating a single document simultaneously.

Things you might want to try:

- creating an in-memory copy of the document you're operating on and using strict xerces/xqilla or another approach to the operations you're performing on the document.

- refactoring your database so that everything you're trying to operate on isn't contained in one single, monolithic document within the database. Find the element that repeats the most frequently within your document and break it down into multiple documents containing that element within the database. Think of it as "XML database normalization" - while you can insert a single, huge document into an XML database and perform operations on it, it kind of defeats the purpose of having a database in the first place if you're not optimizing your storage (and, subsequently, your indexing/optimization/query/etc.) capabilities.

Neither suggestion is ideal from an application maintenance perspective, but hopefully your application architecture allows for modification/optimization of the database operations without having a large imprint on the rest of the application itself...