{"action":"created","issue":{"url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/2","labels_url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/2/comments","events_url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/2/events","html_url":"https://github.com/dresende/node-orm-transaction/issues/2","id":16754622,"number":2,"title":"Transactions do not work together with connection pooling","user":{"login":"TiddoLangerak","id":1759192,"avatar_url":"https://avatars.githubusercontent.com/u/1759192?v=3","gravatar_id":"","url":"https://api.github.com/users/TiddoLangerak","html_url":"https://github.com/TiddoLangerak","followers_url":"https://api.github.com/users/TiddoLangerak/followers","following_url":"https://api.github.com/users/TiddoLangerak/following{/other_user}","gists_url":"https://api.github.com/users/TiddoLangerak/gists{/gist_id}","starred_url":"https://api.github.com/users/TiddoLangerak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TiddoLangerak/subscriptions","organizations_url":"https://api.github.com/users/TiddoLangerak/orgs","repos_url":"https://api.github.com/users/TiddoLangerak/repos","events_url":"https://api.github.com/users/TiddoLangerak/events{/privacy}","received_events_url":"https://api.github.com/users/TiddoLangerak/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dresende/node-orm-transaction/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2013-07-15T13:48:19Z","updated_at":"2015-02-28T02:15:38Z","closed_at":null,"body":"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. \r\n\r\nOne 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.\r\n\r\nI'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."},"comment":{"url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/comments/76504884","html_url":"https://github.com/dresende/node-orm-transaction/issues/2#issuecomment-76504884","issue_url":"https://api.github.com/repos/dresende/node-orm-transaction/issues/2","id":76504884,"user":{"login":"odirus","id":3685998,"avatar_url":"https://avatars.githubusercontent.com/u/3685998?v=3","gravatar_id":"","url":"https://api.github.com/users/odirus","html_url":"https://github.com/odirus","followers_url":"https://api.github.com/users/odirus/followers","following_url":"https://api.github.com/users/odirus/following{/other_user}","gists_url":"https://api.github.com/users/odirus/gists{/gist_id}","starred_url":"https://api.github.com/users/odirus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odirus/subscriptions","organizations_url":"https://api.github.com/users/odirus/orgs","repos_url":"https://api.github.com/users/odirus/repos","events_url":"https://api.github.com/users/odirus/events{/privacy}","received_events_url":"https://api.github.com/users/odirus/received_events","type":"User","site_admin":false},"created_at":"2015-02-28T02:15:38Z","updated_at":"2015-02-28T02:15:38Z","body":"I'm running into the same issue"}}