rdf4j icon indicating copy to clipboard operation
rdf4j copied to clipboard

TimeLimitIteration calls close() asynchronously from another thread

Open kenwenzel opened this issue 9 months ago • 8 comments

Current Behavior

Instead of just setting the isInterrupted flag, the close() method is directly called from interrupt(). The latter method is executed within an asynchronous thread which leads to race conditions if the iterator expects non-multithreaded usage (which is the usual case).

This seems to affect the LmdbRecordIterator that causes a A heap has been corrupted exception at least under Windows.

Expected Behavior

The close() method should not be called asynchronously from another thread. Maybe a global ThreadLocal should be introduced which provides access to isInterrupted or directly a checkInterrupted() method that throws an exception. Then its up to the individual iterators to check the interrupted state and stop the execution.

Another solution would be to explicitly support the asynchronous invocation of close() in LmdbRecordIterator.

Steps To Reproduce

No response

Version

4.2.2

Are you interested in contributing a solution yourself?

Perhaps?

Anything else?

No response

kenwenzel avatar Oct 10 '23 15:10 kenwenzel