{"action":"closed","issue":{"url":"https://api.github.com/repos/zacstewart/tech404logs/issues/15","repository_url":"https://api.github.com/repos/zacstewart/tech404logs","labels_url":"https://api.github.com/repos/zacstewart/tech404logs/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/zacstewart/tech404logs/issues/15/comments","events_url":"https://api.github.com/repos/zacstewart/tech404logs/issues/15/events","html_url":"https://github.com/zacstewart/tech404logs/issues/15","id":120014655,"number":15,"title":"User creation isn't always upserting correctly","user":{"login":"zacstewart","id":435548,"avatar_url":"https://avatars.githubusercontent.com/u/435548?v=3","gravatar_id":"","url":"https://api.github.com/users/zacstewart","html_url":"https://github.com/zacstewart","followers_url":"https://api.github.com/users/zacstewart/followers","following_url":"https://api.github.com/users/zacstewart/following{/other_user}","gists_url":"https://api.github.com/users/zacstewart/gists{/gist_id}","starred_url":"https://api.github.com/users/zacstewart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zacstewart/subscriptions","organizations_url":"https://api.github.com/users/zacstewart/orgs","repos_url":"https://api.github.com/users/zacstewart/repos","events_url":"https://api.github.com/users/zacstewart/events{/privacy}","received_events_url":"https://api.github.com/users/zacstewart/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/zacstewart/tech404logs/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2015-12-02T19:14:03Z","updated_at":"2016-07-19T16:10:04Z","closed_at":"2016-07-19T16:10:04Z","body":"When a new user joins the team, it seems like I try to create it twice, causing a SQL exception.\r\n\r\nI think it's because I get a `team_join` event and a `channel_join` (for #general) nearly simultaneously, and they both get handled at the same time asynchronously.\r\n```\r\n A, [2015-12-02T02:49:12.674688 #6] ANY -- : 2015-12-02 02:49:12 +0000 severity=DEBUG, RTM message received: {\"type\":\"presence_change\",\"user\":\"U0CFPFSTW\",\"presence\":\"away\"}\r\n» 1 Dec 2015 21:49:13.076 2015-12-02 02:49:12.706708+00:00 app web.1 - - A, [2015-12-02T02:49:12.706635 #6] ANY -- : 2015-12-02 02:49:12 +0000 severity=DEBUG, RTM message received: {\"type\":\"presence_change\",\"user\":\"U03HA8NTF\",\"presence\":\"away\"}\r\n» 1 Dec 2015 21:49:13.132 2015-12-02 02:49:12.770786+00:00 app web.1 - - A, [2015-12-02T02:49:12.770714 #6] ANY -- : 2015-12-02 02:49:12 +0000 severity=DEBUG, RTM message received: {\"type\":\"presence_change\",\"user\":\"U04B1MYEV\",\"presence\":\"away\"}\r\n» 1 Dec 2015 21:49:13.997 2015-12-02 02:49:13.701632+00:00 app web.1 - - A, [2015-12-02T02:49:13.701525 #6] ANY -- : 2015-12-02 02:49:13 +0000 severity=DEBUG, RTM message received: {\"type\":\"team_join\",\"user\":{\"id\":\"U0FM52NPP\",\"team_id\":\"T03GVRCFS\",\"name\":\"smagic39\",\"deleted\":false,\"status\":null,\"color\":\"8f4a2b\",\"real_name\":\"\",\"tz\":\"Asia/Novosibirsk\",\"tz_label\":\"Novosibirsk Time\",\"tz_offset\":21600,\"profile\":{\"avatar_hash\":\"g83b9dd9c17c\",\"real_name\":\"\",\"real_name_normalized\":\"\",\"email\":\"smagic39@gmail.com\",\"image_24\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=24&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F66f9%2Fimg%2Favatars%2Fava_0004-24.png\",\"image_32\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=32&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F66f9%2Fimg%2Favatars%2Fava_0004-32.png\",\"image_48\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=48&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F66f9%2Fimg%2Favatars%2Fava_0004-48.png\",\"image_72\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=72&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F66f9%2Fimg%2Favatars%2Fava_0004-72.png\",\"image_192\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=192&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F7fa9%2Fimg%2Favatars%2Fava_0004-192.png\",\"image_512\":\"https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=512&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F7fa9%2Fimg%2Favatars%2Fava_0004-512.png\",\"fields\":null},\"is_admin\":false,\"is_owner\":false,\"is_primary_owner\":false,\"is_restricted\":false,\"is_ultra_restricted\":false,\"is_bot\":false,\"presence\":\"away\"},\"cache_ts\":1449024553}\r\n» 1 Dec 2015 21:49:17.539 2015-12-02 02:49:17.255470+00:00 app web.1 - - A, [2015-12-02T02:49:17.255381 #6] ANY -- : 2015-12-02 02:49:17 +0000 severity=DEBUG, RTM message received: {\"user\":\"U0FM52NPP\",\"type\":\"message\",\"subtype\":\"channel_join\",\"text\":\"<@U0FM52NPP|smagic39> has joined the channel\",\"channel\":\"C03GVRCGE\",\"ts\":\"1449024553.001721\"}\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.256889+00:00 app web.1 - - ~ (0.000706) SET standard_conforming_strings = on\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.258263+00:00 app web.1 - - ~ (0.000683) SET datestyle = ISO\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.276230+00:00 app web.1 - - ~ (0.000691) SET backslash_quote = off\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.277550+00:00 app web.1 - - ~ (0.000589) SET client_min_messages = warning\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.278948+00:00 app web.1 - - ~ default: begin\r\n» 1 Dec 2015 21:49:17.625 2015-12-02 02:49:17.282707+00:00 app web.1 - - ~ (0.001933) SELECT \"id\", \"name\", \"real_name\", \"image\" FROM \"tech404_index_users\" WHERE \"id\" = 'U0FM52NPP' ORDER BY \"id\" LIMIT 1\r\n» 1 Dec 2015 21:49:17.648 2015-12-02 02:49:17.256144+00:00 app web.1 - - ~ (0.000988) SET backslash_quote = off\r\n» 1 Dec 2015 21:49:17.745 2015-12-02 02:49:17.257538+00:00 app web.1 - - ~ (0.000611) SET client_min_messages = warning\r\n» 1 Dec 2015 21:49:17.745 2015-12-02 02:49:17.275698+00:00 app web.1 - - ~ (0.016561) SELECT \"id\", \"name\", \"real_name\", \"image\" FROM \"tech404_index_users\" WHERE \"id\" = 'U0FM52NPP' ORDER BY \"id\" LIMIT 1\r\n» 1 Dec 2015 21:49:17.745 2015-12-02 02:49:17.276921+00:00 app web.1 - - ~ (0.000645) SET standard_conforming_strings = on\r\n» 1 Dec 2015 21:49:17.745 2015-12-02 02:49:17.278201+00:00 app web.1 - - ~ (0.000620) SET datestyle = ISO\r\n» 1 Dec 2015 21:49:17.745 2015-12-02 02:49:17.280303+00:00 app web.1 - - ~ (0.000592) BEGIN\r\n» 1 Dec 2015 21:49:17.894 2015-12-02 02:49:17.611667+00:00 app web.1 - - ~ (0.331980) INSERT INTO \"tech404_index_users\" (\"id\", \"name\", \"real_name\", \"image\") VALUES ('U0FM52NPP', 'smagic39', '', 'https://secure.gravatar.com/avatar/83b9dd9c17cdced7f9e805e06d93dc76.jpg?s=48&d=https%3A%2F%2Fslack.global.ssl.fastly.net%2F66f9%2Fimg%2Favatars%2Fava_0004-48.png')\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.619865+00:00 app web.1 - - ~ ERROR: duplicate key value violates unique constraint \"tech404_index_users_pkey\"\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.619867+00:00 app web.1 - - DETAIL: Key (id)=(U0FM52NPP) already exists.\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.619868+00:00 app web.1 - - (code: 83906754, sql state: 23505, query: INSERT INTO \"tech404_index_users\" (\"id\") VALUES ('U0FM52NPP'), uri: postgres:vmqaqlormfetno@ec2-54-197-238-19.compute-1.amazonaws.com:5432/d8gpnnp2d6fpd4?scheme=postgres&user=vmqaqlormfetno&password=eRISDClarSJZooz1YNw9_9DTyr&host=ec2-54-197-238-19.compute-1.amazonaws.com&port=5432&path=/d8gpnnp2d6fpd4&query=&fragment=&adapter=postgres)\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.621052+00:00 app web.1 - - ~ default: rollback\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.622488+00:00 app web.1 - - A, [2015-12-02T02:49:17.622433 #6] ANY -- : 2015-12-02 02:49:17 +0000 severity=DEBUG, RTM connection closed: 1006,\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.612119+00:00 app web.1 - - ~ (0.328882) INSERT INTO \"tech404_index_users\" (\"id\") VALUES ('U0FM52NPP')\r\n» 1 Dec 2015 21:49:17.896 2015-12-02 02:49:17.621790+00:00 app web.1 - - ~ (0.000640) ROLLBACK\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826159+00:00 app web.1 - - /app/vendor/bundle/ruby/2.0.0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `execute_non_query': ERROR: duplicate key value violates unique constraint \"tech404_index_users_pkey\" (DataObjects::IntegrityError) Exception\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826162+00:00 app web.1 - - DETAIL: Key (id)=(U0FM52NPP) already exists.\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826163+00:00 app web.1 - - from /app/vendor/bundle/ruby/2.0.0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `block (2 levels) in create'\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826164+00:00 app web.1 - - from /app/vendor/bundle/ruby/2.0.0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826164+00:00 app web.1 - - from /app/vendor/bundle/ruby/2.0.0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:113:in `block in create'\r\n» 1 Dec 2015 21:49:17.897 2015-12-02 02:49:17.826165+00:00 app web.1 - - from /app/vendor/bundle/ruby/2.0.0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:85:in `each'\r\n```"}}
{"actor":{"display_login":"zacstewart"}}