{"action":"opened","issue":{"url":"https://api.github.com/repos/magnusvk/counter_culture/issues/120","labels_url":"https://api.github.com/repos/magnusvk/counter_culture/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/magnusvk/counter_culture/issues/120/comments","events_url":"https://api.github.com/repos/magnusvk/counter_culture/issues/120/events","html_url":"https://github.com/magnusvk/counter_culture/issues/120","id":123571300,"number":120,"title":"Move counter cache update back into transaction","user":{"login":"magnusvk","id":704153,"avatar_url":"https://avatars.githubusercontent.com/u/704153?v=3","gravatar_id":"","url":"https://api.github.com/users/magnusvk","html_url":"https://github.com/magnusvk","followers_url":"https://api.github.com/users/magnusvk/followers","following_url":"https://api.github.com/users/magnusvk/following{/other_user}","gists_url":"https://api.github.com/users/magnusvk/gists{/gist_id}","starred_url":"https://api.github.com/users/magnusvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magnusvk/subscriptions","organizations_url":"https://api.github.com/users/magnusvk/orgs","repos_url":"https://api.github.com/users/magnusvk/repos","events_url":"https://api.github.com/users/magnusvk/events{/privacy}","received_events_url":"https://api.github.com/users/magnusvk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-22T22:48:41Z","updated_at":"2015-12-22T22:48:41Z","closed_at":null,"body":"Currently, the counter cache update happens outside of the transaction in the after_commit hook. This is to avoid a historical deadlock issue in Postgres. However, this should be fixed in Postgres 9.3, [according to this](http://mina.naguib.ca/blog/2010/11/22/postgresql-foreign-key-deadlocks.html) and the release notes. \r\n\r\nGiven that, it should be optional in counter_culture whether the update should happen in or outside of the transaction. It should default to inside the transaction. "}}