{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22101","labels_url":"https://api.github.com/repos/rails/rails/issues/22101/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22101/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22101/events","html_url":"https://github.com/rails/rails/pull/22101","id":113894989,"number":22101,"title":"Avoid disabling postgres errors","user":{"login":"hmarr","id":110275,"avatar_url":"https://avatars.githubusercontent.com/u/110275?v=3","gravatar_id":"","url":"https://api.github.com/users/hmarr","html_url":"https://github.com/hmarr","followers_url":"https://api.github.com/users/hmarr/followers","following_url":"https://api.github.com/users/hmarr/following{/other_user}","gists_url":"https://api.github.com/users/hmarr/gists{/gist_id}","starred_url":"https://api.github.com/users/hmarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmarr/subscriptions","organizations_url":"https://api.github.com/users/hmarr/orgs","repos_url":"https://api.github.com/users/hmarr/repos","events_url":"https://api.github.com/users/hmarr/events{/privacy}","received_events_url":"https://api.github.com/users/hmarr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"pixeltrix","id":6321,"avatar_url":"https://avatars.githubusercontent.com/u/6321?v=3","gravatar_id":"","url":"https://api.github.com/users/pixeltrix","html_url":"https://github.com/pixeltrix","followers_url":"https://api.github.com/users/pixeltrix/followers","following_url":"https://api.github.com/users/pixeltrix/following{/other_user}","gists_url":"https://api.github.com/users/pixeltrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pixeltrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixeltrix/subscriptions","organizations_url":"https://api.github.com/users/pixeltrix/orgs","repos_url":"https://api.github.com/users/pixeltrix/repos","events_url":"https://api.github.com/users/pixeltrix/events{/privacy}","received_events_url":"https://api.github.com/users/pixeltrix/received_events","type":"User","site_admin":false},"milestone":null,"comments":14,"created_at":"2015-10-28T18:47:50Z","updated_at":"2015-10-29T20:03:54Z","closed_at":"2015-10-29T16:44:18Z","pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/22101","html_url":"https://github.com/rails/rails/pull/22101","diff_url":"https://github.com/rails/rails/pull/22101.diff","patch_url":"https://github.com/rails/rails/pull/22101.patch"},"body":"The standard_conforming_strings setting doesn't exist on all versions of\r\nPostgres, but if it does exist, Rails turns it on. Previously this was done by\r\neffectively disabling errors on the Postgres connection, issuing a SET to turn\r\nthe setting on, then re-enabling errors on the connection. However, if you're\r\nrunning pgbouncer in transaction-pooling mode, you can't guarantee that\r\nsuccessive calls to `#execute` will be sent to the same pgbouncer-postgres\r\nconnection, so you can end up disabling errors on a different postgres\r\nconnection, and never re-enabling them. Future queries on that connection that\r\nresult in errors (e.g. violating unique constraints) will leave the connection\r\nin a bad state where successive queries will fail.\r\n\r\nThis commit sets standard_conforming_strings by issuing an UPDATE to\r\npg_settings, which will update the setting if it exists, and do nothing if it\r\ndoesn't (rather than erroring out like SET would), which means we can remove\r\nthe error-disabling code.\r\n\r\nIt's also worth noting that Postgres has allowed standard_conforming_strings to\r\nbe updated since 8.2 (which is the oldest version Rails supports), so\r\ntechnically we probably don't even need to be defensive here.\r\n\r\nThis is related to a larger issue about Rails' use of connection-level\r\nfeatures, which we're writing up and will open an issue for soon."},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/152303108","html_url":"https://github.com/rails/rails/pull/22101#issuecomment-152303108","issue_url":"https://api.github.com/repos/rails/rails/issues/22101","id":152303108,"user":{"login":"hmarr","id":110275,"avatar_url":"https://avatars.githubusercontent.com/u/110275?v=3","gravatar_id":"","url":"https://api.github.com/users/hmarr","html_url":"https://github.com/hmarr","followers_url":"https://api.github.com/users/hmarr/followers","following_url":"https://api.github.com/users/hmarr/following{/other_user}","gists_url":"https://api.github.com/users/hmarr/gists{/gist_id}","starred_url":"https://api.github.com/users/hmarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmarr/subscriptions","organizations_url":"https://api.github.com/users/hmarr/orgs","repos_url":"https://api.github.com/users/hmarr/repos","events_url":"https://api.github.com/users/hmarr/events{/privacy}","received_events_url":"https://api.github.com/users/hmarr/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T20:03:54Z","updated_at":"2015-10-29T20:03:54Z","body":"@pixeltrix thanks, submitting a PR momentarily!"}}