{"action":"created","issue":{"url":"https://api.github.com/repos/taskrabbit/makara/issues/70","labels_url":"https://api.github.com/repos/taskrabbit/makara/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/taskrabbit/makara/issues/70/comments","events_url":"https://api.github.com/repos/taskrabbit/makara/issues/70/events","html_url":"https://github.com/taskrabbit/makara/issues/70","id":51481337,"number":70,"title":"Dealing with SET Edge cases","user":{"login":"dvodvo","id":716130,"avatar_url":"https://avatars.githubusercontent.com/u/716130?v=3","gravatar_id":"","url":"https://api.github.com/users/dvodvo","html_url":"https://github.com/dvodvo","followers_url":"https://api.github.com/users/dvodvo/followers","following_url":"https://api.github.com/users/dvodvo/following{/other_user}","gists_url":"https://api.github.com/users/dvodvo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvodvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvodvo/subscriptions","organizations_url":"https://api.github.com/users/dvodvo/orgs","repos_url":"https://api.github.com/users/dvodvo/repos","events_url":"https://api.github.com/users/dvodvo/events{/privacy}","received_events_url":"https://api.github.com/users/dvodvo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-12-09T21:03:57Z","updated_at":"2015-04-26T23:44:47Z","closed_at":null,"body":"As README states: `The only edge case is SET operations which are sent to all connections.` Devise controller is using SET and thus leading to an error which one would like to avoid:\r\n`PG::ReadOnlySqlTransaction: ERROR:  cannot execute UPDATE in a read-only transaction\r\n: UPDATE \"users\" SET \"last_sign_in_at\" = '2014-12-09 19:58:58.290982', [...]`\r\nnotwithstanding the creation of an sql_proxy.rb initializer that should only handle select on the slave, as follows:\r\n\r\n    class MakaraSqlProxy < ::Makara::Proxy\r\n      def connection_for(config)\r\n        ::Sql::Client.new(config)\r\n      end\r\n    \r\n      hijack_method :select, :ping\r\n      send_to_all :connect, :reconnect, :disconnect, :clear_cache\r\n    \r\n      def needs_master?(method_name, args)\r\n        return false if args.empty?\r\n        sql = args.first\r\n        sql !~ /^select/i\r\n      end\r\n    \r\n    end"},"comment":{"url":"https://api.github.com/repos/taskrabbit/makara/issues/comments/96448617","html_url":"https://github.com/taskrabbit/makara/issues/70#issuecomment-96448617","issue_url":"https://api.github.com/repos/taskrabbit/makara/issues/70","id":96448617,"user":{"login":"righi","id":219317,"avatar_url":"https://avatars.githubusercontent.com/u/219317?v=3","gravatar_id":"","url":"https://api.github.com/users/righi","html_url":"https://github.com/righi","followers_url":"https://api.github.com/users/righi/followers","following_url":"https://api.github.com/users/righi/following{/other_user}","gists_url":"https://api.github.com/users/righi/gists{/gist_id}","starred_url":"https://api.github.com/users/righi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/righi/subscriptions","organizations_url":"https://api.github.com/users/righi/orgs","repos_url":"https://api.github.com/users/righi/repos","events_url":"https://api.github.com/users/righi/events{/privacy}","received_events_url":"https://api.github.com/users/righi/received_events","type":"User","site_admin":false},"created_at":"2015-04-26T23:44:47Z","updated_at":"2015-04-26T23:44:47Z","body":"@mnelson Thanks! That's exactly what I did.\r\n\r\nThis does introduce the possibility that SET statements don't get passed to all connections when they should. For example if somebody is using instrumentation middleware that puts comments at the beginning of statements:\r\n\r\n```ruby\r\nproxy.execute(\"/*application:myapp,controller:foo,action:bar*/nSET @@some_variable\")\r\n```\r\n\r\nThis probably isn't common enough to warrant a more precise regex at the expense of speed, but wanted to point it out."}}