{"action":"created","issue":{"url":"https://api.github.com/repos/basecamp/marginalia/issues/49","repository_url":"https://api.github.com/repos/basecamp/marginalia","labels_url":"https://api.github.com/repos/basecamp/marginalia/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/basecamp/marginalia/issues/49/comments","events_url":"https://api.github.com/repos/basecamp/marginalia/issues/49/events","html_url":"https://github.com/basecamp/marginalia/issues/49","id":82787922,"number":49,"title":"Marginalia with request_id and job_id bloats PostgreSQLAdapter::StatementPool","user":{"login":"keithpitt","id":25882,"avatar_url":"https://avatars.githubusercontent.com/u/25882?v=3","gravatar_id":"","url":"https://api.github.com/users/keithpitt","html_url":"https://github.com/keithpitt","followers_url":"https://api.github.com/users/keithpitt/followers","following_url":"https://api.github.com/users/keithpitt/following{/other_user}","gists_url":"https://api.github.com/users/keithpitt/gists{/gist_id}","starred_url":"https://api.github.com/users/keithpitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithpitt/subscriptions","organizations_url":"https://api.github.com/users/keithpitt/orgs","repos_url":"https://api.github.com/users/keithpitt/repos","events_url":"https://api.github.com/users/keithpitt/events{/privacy}","received_events_url":"https://api.github.com/users/keithpitt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-30T11:30:03Z","updated_at":"2016-05-30T23:13:42Z","closed_at":null,"body":"Hey! I just discovered that if you include the http `request_id` or the `ActiveJob` job id inside the marginalia annotation, it will bloat the the PostgreSQLAdapter::StatementPool cache.\r\n\r\nEach unique SQL query will create a new prepared_statement entry, and because of the unique annotation, it won't get re-used, so it will just sit around in memory doing nothing. Here is the line inside Rails that generates the prepared statement:\r\n\r\nhttps://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L644\r\n\r\nHere is a screenshot of me listing all the entries in the statement pool, and you'll be able to see a query that could have been re-used, but wasn't because of the unique annotation.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/25882/7897074/d81ef548-06ce-11e5-8e62-775d71b48aec.png)\r\n\r\nSo each unique combination of the annotation will result in a new prepared statement entry. I'm not sure how to fix this, or even if there is a possible fix? Maybe use of marginalia means that you can't use the prepared statement cache?"},"comment":{"url":"https://api.github.com/repos/basecamp/marginalia/issues/comments/222564564","html_url":"https://github.com/basecamp/marginalia/issues/49#issuecomment-222564564","issue_url":"https://api.github.com/repos/basecamp/marginalia/issues/49","id":222564564,"user":{"login":"keithpitt","id":25882,"avatar_url":"https://avatars.githubusercontent.com/u/25882?v=3","gravatar_id":"","url":"https://api.github.com/users/keithpitt","html_url":"https://github.com/keithpitt","followers_url":"https://api.github.com/users/keithpitt/followers","following_url":"https://api.github.com/users/keithpitt/following{/other_user}","gists_url":"https://api.github.com/users/keithpitt/gists{/gist_id}","starred_url":"https://api.github.com/users/keithpitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithpitt/subscriptions","organizations_url":"https://api.github.com/users/keithpitt/orgs","repos_url":"https://api.github.com/users/keithpitt/repos","events_url":"https://api.github.com/users/keithpitt/events{/privacy}","received_events_url":"https://api.github.com/users/keithpitt/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T23:13:42Z","updated_at":"2016-05-30T23:13:42Z","body":"@ACPK we actually turned off prepared statements in our app, so I'm not entirely sure!"}}
{"actor":{"display_login":"keithpitt"}}