{"action":"created","issue":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/2018","repository_url":"https://api.github.com/repos/rmosolgo/graphql-ruby","labels_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/2018/labels{/name}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/2018/comments","events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/2018/events","html_url":"https://github.com/rmosolgo/graphql-ruby/issues/2018","id":391981127,"node_id":"MDU6SXNzdWUzOTE5ODExMjc=","number":2018,"title":"Thread unsafe .connection_type","user":{"login":"ajoneil","id":460342,"node_id":"MDQ6VXNlcjQ2MDM0Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/460342?v=4","gravatar_id":"","url":"https://api.github.com/users/ajoneil","html_url":"https://github.com/ajoneil","followers_url":"https://api.github.com/users/ajoneil/followers","following_url":"https://api.github.com/users/ajoneil/following{/other_user}","gists_url":"https://api.github.com/users/ajoneil/gists{/gist_id}","starred_url":"https://api.github.com/users/ajoneil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajoneil/subscriptions","organizations_url":"https://api.github.com/users/ajoneil/orgs","repos_url":"https://api.github.com/users/ajoneil/repos","events_url":"https://api.github.com/users/ajoneil/events{/privacy}","received_events_url":"https://api.github.com/users/ajoneil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-18T03:24:01Z","updated_at":"2018-12-20T06:20:56Z","closed_at":null,"author_association":"NONE","body":"Routinely after deploying our site to production, we get a handful of errors like the following:\r\n`Duplicate type definition found for name 'DuplicateClusterConnection' `\r\nNormally these are just a couple of errors around deploy time, but a recent deploy generated this error for every request.\r\n\r\nAfter some debugging, I believe the issue is due to race conditions in `GraphQL::Schema::Member::RelayShortcuts.connection_type`: https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/member/relay_shortcuts.rb#L34\r\nWe're running puma, which is multithreaded, and the `||=` operator is not thread safe. If this connection is used in multiple places in the graph, multiple classes can be generated, and the single definition check [here](https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/traversal.rb#L168) throws an error.\r\n\r\nPossible solutions are to either provide thread safety in `connection_type`, possibly with https://github.com/reidmorrison/sync_attr or similar, or to relax the duplicate checks for the generated connection class. Happy to put up a PR for either of these, if I know which of the options is more desirable. :)"},"comment":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/comments/448886863","html_url":"https://github.com/rmosolgo/graphql-ruby/issues/2018#issuecomment-448886863","issue_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/2018","id":448886863,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODg4Njg2Mw==","user":{"login":"nekogami","id":594893,"node_id":"MDQ6VXNlcjU5NDg5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/594893?v=4","gravatar_id":"","url":"https://api.github.com/users/nekogami","html_url":"https://github.com/nekogami","followers_url":"https://api.github.com/users/nekogami/followers","following_url":"https://api.github.com/users/nekogami/following{/other_user}","gists_url":"https://api.github.com/users/nekogami/gists{/gist_id}","starred_url":"https://api.github.com/users/nekogami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nekogami/subscriptions","organizations_url":"https://api.github.com/users/nekogami/orgs","repos_url":"https://api.github.com/users/nekogami/repos","events_url":"https://api.github.com/users/nekogami/events{/privacy}","received_events_url":"https://api.github.com/users/nekogami/received_events","type":"User","site_admin":false},"created_at":"2018-12-20T06:20:56Z","updated_at":"2018-12-20T06:20:56Z","author_association":"NONE","body":"That bug was mentionned I think in another issue, the workaround meanwhile is to call MySchema.graphql_definition just after your schema declaration to \"cheat\" the system.\r\n"}}
{"actor":{"display_login":"nekogami"}}