{"action":"created","issue":{"url":"https://api.github.com/repos/deployd/deployd/issues/682","labels_url":"https://api.github.com/repos/deployd/deployd/issues/682/labels{/name}","comments_url":"https://api.github.com/repos/deployd/deployd/issues/682/comments","events_url":"https://api.github.com/repos/deployd/deployd/issues/682/events","html_url":"https://github.com/deployd/deployd/pull/682","id":117758155,"number":682,"title":"fix(session): use update for updating sessions, not remove and insert","user":{"login":"iKristjan","id":744817,"avatar_url":"https://avatars.githubusercontent.com/u/744817?v=3","gravatar_id":"","url":"https://api.github.com/users/iKristjan","html_url":"https://github.com/iKristjan","followers_url":"https://api.github.com/users/iKristjan/followers","following_url":"https://api.github.com/users/iKristjan/following{/other_user}","gists_url":"https://api.github.com/users/iKristjan/gists{/gist_id}","starred_url":"https://api.github.com/users/iKristjan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iKristjan/subscriptions","organizations_url":"https://api.github.com/users/iKristjan/orgs","repos_url":"https://api.github.com/users/iKristjan/repos","events_url":"https://api.github.com/users/iKristjan/events{/privacy}","received_events_url":"https://api.github.com/users/iKristjan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-19T07:31:40Z","updated_at":"2015-11-19T15:31:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/deployd/deployd/pulls/682","html_url":"https://github.com/deployd/deployd/pull/682","diff_url":"https://github.com/deployd/deployd/pull/682.diff","patch_url":"https://github.com/deployd/deployd/pull/682.patch"},"body":"Session update is currently implemented with remove and insert. During the update when the session is removed for a moment and then inserted again, a concurrent query can fail finding the session and result as an anonymous query.\r\n\r\nIt took a while to find the source of the problem, because it’s difficult to test it. It can happen only after every 10 seconds when the \"lastActive\" timestamp is updated and when you have another query at the same time, which resulted unauthorized response in my case.\r\n\r\nThis PR fixes the issue so that new sessions are inserted and old sessions are updated as they should, which allows concurrent queries to find the active session and authorize the user."},"comment":{"url":"https://api.github.com/repos/deployd/deployd/issues/comments/158090624","html_url":"https://github.com/deployd/deployd/pull/682#issuecomment-158090624","issue_url":"https://api.github.com/repos/deployd/deployd/issues/682","id":158090624,"user":{"login":"andreialecu","id":697707,"avatar_url":"https://avatars.githubusercontent.com/u/697707?v=3","gravatar_id":"","url":"https://api.github.com/users/andreialecu","html_url":"https://github.com/andreialecu","followers_url":"https://api.github.com/users/andreialecu/followers","following_url":"https://api.github.com/users/andreialecu/following{/other_user}","gists_url":"https://api.github.com/users/andreialecu/gists{/gist_id}","starred_url":"https://api.github.com/users/andreialecu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreialecu/subscriptions","organizations_url":"https://api.github.com/users/andreialecu/orgs","repos_url":"https://api.github.com/users/andreialecu/repos","events_url":"https://api.github.com/users/andreialecu/events{/privacy}","received_events_url":"https://api.github.com/users/andreialecu/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T15:31:10Z","updated_at":"2015-11-19T15:31:10Z","body":"I'm going to merge this. It's an improvement to an existing code path, and it's hard to unit test for the specific race-condition problem that was happening.\r\n\r\nThanks @iKristjan!"}}