{"action":"opened","issue":{"url":"https://api.github.com/repos/awslabs/pgbouncer-rr-patch/issues/14","repository_url":"https://api.github.com/repos/awslabs/pgbouncer-rr-patch","labels_url":"https://api.github.com/repos/awslabs/pgbouncer-rr-patch/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/pgbouncer-rr-patch/issues/14/comments","events_url":"https://api.github.com/repos/awslabs/pgbouncer-rr-patch/issues/14/events","html_url":"https://github.com/awslabs/pgbouncer-rr-patch/issues/14","id":182821802,"number":14,"title":"Routing breaks session based pooling when prepared statements are used","user":{"login":"gilesw","id":201443,"avatar_url":"https://avatars.githubusercontent.com/u/201443?v=3","gravatar_id":"","url":"https://api.github.com/users/gilesw","html_url":"https://github.com/gilesw","followers_url":"https://api.github.com/users/gilesw/followers","following_url":"https://api.github.com/users/gilesw/following{/other_user}","gists_url":"https://api.github.com/users/gilesw/gists{/gist_id}","starred_url":"https://api.github.com/users/gilesw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilesw/subscriptions","organizations_url":"https://api.github.com/users/gilesw/orgs","repos_url":"https://api.github.com/users/gilesw/repos","events_url":"https://api.github.com/users/gilesw/events{/privacy}","received_events_url":"https://api.github.com/users/gilesw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-13T15:26:47Z","updated_at":"2016-10-13T15:26:47Z","closed_at":null,"body":"When routing rules are enabled I hit this crash when a prepared statement is used.\r\n\r\n```\r\ndef routing_rules(username, query):\r\n    if \"select\" in query:\r\n        return \"read\"\r\n    elif \"SELECT\" in query:\r\n        return \"read\"\r\n    else:\r\n        return \"write\"\r\n```\r\n\r\n\r\n```\r\nopen(\"/etc/pgbouncer/routing_rules/routing_rules.pyc\", O_RDONLY) = 24\r\nfstat(24, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0                                                                                                     mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe916fd1000\r\nread(24, \"\\3\\363\\r\\n\\250\\237\\377Wc\\0\\0\\0\\0\\0\\0\\0\\0\\1\\0\\0\\0@\\0\\0\\0s\\r\\0\\0\\0d\\0\"..., 4096) = 388\r\nfstat(24, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0\r\nread(24, \"\", 4096)                      = 0\r\nclose(24)                               = 0\r\nmunmap(0x7fe916fd1000, 4096)            = 0\r\nclose(23)                               = 0\r\nwrite(2, \"2016-10-13 15:57:21.734 2085 FAT\"..., 1162016-10-13 15:57:21.734 2085 FATAL @src/objects.c:299 in function put_in_order(): put_in_order: found existing elem\r\n) = 116\r\nwrite(3, \"2016-10-13 15:57:21.734 2085 FAT\"..., 116) = 116\r\nsendto(4, \"<26>Oct 13 15:57:21 pgbouncer[20\"..., 117, MSG_NOSIGNAL, NULL, 0) = 117\r\nunlink(\"/var/run/postgresql/pgbouncer.pid\") = 0\r\nclose(10)                               = 0\r\nclose(11)                               = 0\r\nunlink(\"/var/run/postgresql/.s.PGSQL.6432\") = 0\r\nexit_group(1)                           = ?\r\n\r\n\r\n```\r\n\r\nRemoving the line:-\r\n\r\nrouting_rules_py_module_file = /etc/pgbouncer/routing_rules/routing_rules.py\r\n\r\nand re-running produces no error.\r\n\r\nI suspect there's an issue when switching between the default connection and the one that is hit but the routing rules. Or possibly routing rules switches on statement pooling. I've yet to check the code.\r\n\r\nI don't have the prepared statement as it's generated by an application but I can sniff/log it if needed.\r\n\r\nTesting a simple update or select works fine.\r\n\r\n"}}
{"actor":{"display_login":"gilesw"}}