Transactions do not work together with connection pooling
I've noticed that when using the pooling option in node-orm2 that transactions don't work anymore. The source code of node-orm revealed that when pooling is used a new (or cached) connection is requested for every query executed (both for postgres and mysql). However, this also happens for queries inside a transaction. Therefore queries are executed using different connections and as a result these queries are no longer inside one transaction. Transactions should all be executed over one connection and a connection in a transaction should not be used for other queries as well.
One possible solution for this problem is that queries can be passed a connection/transaction object, such that users can manually group queries together in one transaction. Also, the connection used for a transaction should be removed from the pool as soon as the transaction starts and should be re-added as soon as the transaction is finished. This does require some modifications in the node-orm module however.
I'm happy to help fixing this problem, but since a solution to this problem requires modifying quite some code both in the node-orm module and most likely changes to the interface of either node-orm or this module it seemed best to me to discuss this first with you.
Thank you for pointing this out, it's actually not simple to solve. I have to look at it more closely. The Driver class has to change to be able maybe to force a connection handler or something and don't dispose it..
I was thinking about this and perhaps the "simplest" way is to change the mysql driver in orm to get a connection and keep it for a while. If a period of inactivity occurs, it just drops the link. If you keep using it it just keeps it.
Any progress about this issue ?
Hi, has there been any progress on this? I'm running into the same issue.
I'm running into the same issue
same issue here..
+1
+1