lolgab opened a new issue, #2200: URL: https://github.com/apache/jena/issues/2200
### Version 4.10.0 ### Feature I want to use Jena in a [cats-effect](https://typelevel.org/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](https://github.com/apache/jena/blob/3a580054a1b3481e12a23f1ea6d3123a9b8212e0/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionalBase.java#L40) Jena maintains a `ThreadLocal` of a `Transaction` so only one can exist per thread. In [TransactionCoordinator](https://github.com/apache/jena/blob/3a580054a1b3481e12a23f1ea6d3123a9b8212e0/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionCoordinator.java#L97) 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 a `TDB2StorageBuilder` is via its [`build`](https://github.com/apache/jena/blob/22d30fdeedd3ad5756af73899dcdff257e2c69b9/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/TDB2StorageBuilder.java#L80) static methods which hardcode the TransactionalSystem to use `TransactionalBase` 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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
