Support passing a custom TransactionalSystem
in TDB2StorageBuilder
#2200
Labels
enhancement
Incrementally add new feature
TransactionalSystem
in TDB2StorageBuilder
#2200
Version
4.10.0
Feature
I want to use Jena in a cats-effect Scala application.
Cats Effect uses an asynchronous runtime that implements many concurrency constructs in a "semantic" fashion (for example, blocking on a lock is implemented by waiting to execute a callback, instead of using an actual Java lock).
Cats Effect programs are split into many consecutive callbacks which are then executed by their runtime. The runtime uses many threads that execute the next action available for execution.
With Cats Effect I can implement transactions, but they don't work with Jena, since Jena assumes that your code runs sequentially on the same thread. This assumption is reflected in many places.
In TransactionalBase Jena maintains a
ThreadLocal
of aTransaction
so only one can exist per thread.In TransactionCoordinator Jena uses a
ReentrantReadWriteLock
which doesn't allow to lock it from a thread and unlock it from another.In normal Java code, this makes sense since it's highly unsafe to lock from one thread and unlock from another.
But in Cats Effect code there are other safeguards to make sure that no race conditions happen.
I would like to customize TDB2 to allow using my own
TransactionalSystem
, but this is impossible at the moment since the only way to construct aTDB2StorageBuilder
is via itsbuild
static methods which hardcode the TransactionalSystem to useTransactionalBase
here.If I can implement my own
TransactionalSystem
I think I can disable the built-in transactionality and enforce it in other ways.Are you interested in contributing a solution yourself?
None
The text was updated successfully, but these errors were encountered: