Reason for being multithreaded producer-consumer si simple -- single thread solution is _very_ slow, even now it takes hours to complete.
I see. So just in case it would be interested if the problems also occur with a single thread.
Is it a bug in BASEX (not releasing resources properly?) or is reusing sessions (saved in thread local context) a bad idea and should be discouraged?
I'm not aware of a particular bug in BaseX related to session management, but usually there is no need to reuse existing sessions, as the creation of sessions is pretty light-weight.