{"action":"closed","issue":{"url":"https://api.github.com/repos/felixge/node-mysql/issues/1307","labels_url":"https://api.github.com/repos/felixge/node-mysql/issues/1307/labels{/name}","comments_url":"https://api.github.com/repos/felixge/node-mysql/issues/1307/comments","events_url":"https://api.github.com/repos/felixge/node-mysql/issues/1307/events","html_url":"https://github.com/felixge/node-mysql/issues/1307","id":122480928,"number":1307,"title":"Partial commit when rollback invoked","user":{"login":"jinaraj","id":6458219,"avatar_url":"https://avatars.githubusercontent.com/u/6458219?v=3","gravatar_id":"","url":"https://api.github.com/users/jinaraj","html_url":"https://github.com/jinaraj","followers_url":"https://api.github.com/users/jinaraj/followers","following_url":"https://api.github.com/users/jinaraj/following{/other_user}","gists_url":"https://api.github.com/users/jinaraj/gists{/gist_id}","starred_url":"https://api.github.com/users/jinaraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinaraj/subscriptions","organizations_url":"https://api.github.com/users/jinaraj/orgs","repos_url":"https://api.github.com/users/jinaraj/repos","events_url":"https://api.github.com/users/jinaraj/events{/privacy}","received_events_url":"https://api.github.com/users/jinaraj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-16T11:16:44Z","updated_at":"2015-12-17T12:19:59Z","closed_at":"2015-12-17T12:19:59Z","body":"I am inserting data to two tables here - first Org and then to User. I am deliberately passing an invalid value (5000) into second query (user insert) so that I could test if the entire transaction is rolled back. To my surprise, I can see data in Org table when the second statement throws an execution error. Am I making a mistake here? \r\n\r\ncon.beginTransaction( function (terr){\r\n\tcon.query(\"INSERT into org(email,phone) values(?,?)\", vals, function (oerr, or) {\r\n\t\tif (!oerr) {\r\n\t\t\tuser.orgId = or.insertId;\r\n\t\t\tvals = [user.email, user.phone, ran, 5000];\r\n\t\t\tcon.query(\"INSERT into user (email, phone, otp, org_fk) values (?, ?, ?, ?)\", vals, function (qerr, ur) {\r\n\t\t\t\tif (qerr) {\r\n\t\t\t\t\tcon.rollback(function (){\r\n\t\t\t\t\t\tconsole.log(\"Rolling back\");\r\n\t\t\t\t\t});\r\n\t\t\t\t\tcallback(qerr);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tcallback(null, ur.insertId);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tconsole.log(\"orgSql errrrr : \"+oerr);\r\n\t\t\tcon.rollback(function (){\r\n\t\t\t\tconsole.log(\"Rolling back\");\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n\tcon.commit();\r\n\tcon.release();\r\n});\r\n"}}