{"action":"created","issue":{"url":"https://api.github.com/repos/schotime/NPoco/issues/455","repository_url":"https://api.github.com/repos/schotime/NPoco","labels_url":"https://api.github.com/repos/schotime/NPoco/issues/455/labels{/name}","comments_url":"https://api.github.com/repos/schotime/NPoco/issues/455/comments","events_url":"https://api.github.com/repos/schotime/NPoco/issues/455/events","html_url":"https://github.com/schotime/NPoco/issues/455","id":293349399,"number":455,"title":"Multiple CRUD operations in a transaction causing Deadlock","user":{"login":"RDeveloper1","id":33534766,"avatar_url":"https://avatars1.githubusercontent.com/u/33534766?v=4","gravatar_id":"","url":"https://api.github.com/users/RDeveloper1","html_url":"https://github.com/RDeveloper1","followers_url":"https://api.github.com/users/RDeveloper1/followers","following_url":"https://api.github.com/users/RDeveloper1/following{/other_user}","gists_url":"https://api.github.com/users/RDeveloper1/gists{/gist_id}","starred_url":"https://api.github.com/users/RDeveloper1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RDeveloper1/subscriptions","organizations_url":"https://api.github.com/users/RDeveloper1/orgs","repos_url":"https://api.github.com/users/RDeveloper1/repos","events_url":"https://api.github.com/users/RDeveloper1/events{/privacy}","received_events_url":"https://api.github.com/users/RDeveloper1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-01-31T23:25:56Z","updated_at":"2018-02-01T04:15:58Z","closed_at":null,"author_association":"NONE","body":"\r\n    using (var transaction = Conn.GetTransaction())\r\n    {\r\n        await Conn.DeleteMany<M1>().Where(x => (x.d == dId).ExecuteAsync();\r\n        foreach (var l in listData)\r\n        {\r\n            await Conn.InsertAsync(l);\r\n        }\r\n        transaction.Complete();\r\n    }\r\n\r\nWhen a method with this logic is called multiple times [>25 times] in a loop. It actually causes a deadlock and few of the records are not inserted.  "},"comment":{"url":"https://api.github.com/repos/schotime/NPoco/issues/comments/362153537","html_url":"https://github.com/schotime/NPoco/issues/455#issuecomment-362153537","issue_url":"https://api.github.com/repos/schotime/NPoco/issues/455","id":362153537,"user":{"login":"tbasallo","id":270673,"avatar_url":"https://avatars1.githubusercontent.com/u/270673?v=4","gravatar_id":"","url":"https://api.github.com/users/tbasallo","html_url":"https://github.com/tbasallo","followers_url":"https://api.github.com/users/tbasallo/followers","following_url":"https://api.github.com/users/tbasallo/following{/other_user}","gists_url":"https://api.github.com/users/tbasallo/gists{/gist_id}","starred_url":"https://api.github.com/users/tbasallo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbasallo/subscriptions","organizations_url":"https://api.github.com/users/tbasallo/orgs","repos_url":"https://api.github.com/users/tbasallo/repos","events_url":"https://api.github.com/users/tbasallo/events{/privacy}","received_events_url":"https://api.github.com/users/tbasallo/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T04:15:58Z","updated_at":"2018-02-01T04:15:58Z","author_association":"NONE","body":"I think what might be happening is as the number of inserts and deletes increases, the DB has less of a chance (the seconds in between each of the commands) to complete the transaction, eventually causing the deadlock.\r\n\r\nAs a test, keep the delete in the transaction, but remove the async. If it runs (all 20) without deadlocking, then it's the async (parallel) nature ('d bet). Really, more of a DB/threading issue than a NPoco issue."}}
{"actor":{"display_login":"tbasallo"}}