{"action":"opened","issue":{"url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/issues/57","labels_url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/issues/57/comments","events_url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/issues/57/events","html_url":"https://github.com/ProfilesRNS/ProfilesRNS/issues/57","id":89031595,"number":57,"title":"Bug in User.Session.Create session that returns incorrect sessionID values and overwrites data in other nodes.","user":{"login":"nicholaswilliambrown","id":2432061,"avatar_url":"https://avatars.githubusercontent.com/u/2432061?v=3","gravatar_id":"","url":"https://api.github.com/users/nicholaswilliambrown","html_url":"https://github.com/nicholaswilliambrown","followers_url":"https://api.github.com/users/nicholaswilliambrown/followers","following_url":"https://api.github.com/users/nicholaswilliambrown/following{/other_user}","gists_url":"https://api.github.com/users/nicholaswilliambrown/gists{/gist_id}","starred_url":"https://api.github.com/users/nicholaswilliambrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicholaswilliambrown/subscriptions","organizations_url":"https://api.github.com/users/nicholaswilliambrown/orgs","repos_url":"https://api.github.com/users/nicholaswilliambrown/repos","events_url":"https://api.github.com/users/nicholaswilliambrown/events{/privacy}","received_events_url":"https://api.github.com/users/nicholaswilliambrown/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/milestones/3","html_url":"https://github.com/ProfilesRNS/ProfilesRNS/milestones/Version%202.7.0","labels_url":"https://api.github.com/repos/ProfilesRNS/ProfilesRNS/milestones/3/labels","id":1087553,"number":3,"title":"Version 2.7.0","description":"","creator":{"login":"nicholaswilliambrown","id":2432061,"avatar_url":"https://avatars.githubusercontent.com/u/2432061?v=3","gravatar_id":"","url":"https://api.github.com/users/nicholaswilliambrown","html_url":"https://github.com/nicholaswilliambrown","followers_url":"https://api.github.com/users/nicholaswilliambrown/followers","following_url":"https://api.github.com/users/nicholaswilliambrown/following{/other_user}","gists_url":"https://api.github.com/users/nicholaswilliambrown/gists{/gist_id}","starred_url":"https://api.github.com/users/nicholaswilliambrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicholaswilliambrown/subscriptions","organizations_url":"https://api.github.com/users/nicholaswilliambrown/orgs","repos_url":"https://api.github.com/users/nicholaswilliambrown/repos","events_url":"https://api.github.com/users/nicholaswilliambrown/events{/privacy}","received_events_url":"https://api.github.com/users/nicholaswilliambrown/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":2,"state":"open","created_at":"2015-04-28T14:12:33Z","updated_at":"2015-06-17T14:20:44Z","due_on":"2015-07-31T04:00:00Z","closed_at":null},"comments":0,"created_at":"2015-06-17T14:20:44Z","updated_at":"2015-06-17T14:20:44Z","closed_at":null,"body":"In the [User.Session].[CreateSession] stored procedure, you see the following chunk of code:\r\n            DECLARE @NodeID BIGINT\r\n            INSERT INTO [RDF.].[Node] (ViewSecurityGroup, EditSecurityGroup, Value, ObjectType, ValueHash)\r\n                  SELECT IDENT_CURRENT('[RDF.].[Node]'), -50, @baseURI+CAST(IDENT_CURRENT('[RDF.].[Node]') as varchar(50)), 0,\r\n                        [RDF.].fnValueHash(null,null,@baseURI+CAST(IDENT_CURRENT('[RDF.].[Node]') as nvarchar(50)))\r\n            SELECT @NodeID = @@IDENTITY\r\n\r\nThat last line is supposed to set the @NodeID variable to equal the value of the nodeID that was just inserted, and that’s what normally happens. However, we are seeing it be set to the SessionSequence of the User.Session.Session table sometimes. This doesn’t happen often, but when it does happen the RDF gets out of sorts and the SemWeb part of the nightly batch job fails.\r\n\r\nAccording to this dude who I’ve been looking at far too often lately (http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/ ) , it could be safer to use the SCOPE_IDENTITY() function instead of the @@IDENTITY value but I’m not sure.\r\n\r\nAlso, if you look at the code below the \r\n            -- Confirm the node values are correct\r\ncomment, in the [User.Session].[CreateSession] SP, it seems that I’m not the only one who’s found weirdness in this SP….\r\n"}}