{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3529","repository_url":"https://api.github.com/repos/Starcounter/Starcounter","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3529/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3529/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3529/events","html_url":"https://github.com/Starcounter/Starcounter/issues/3529","id":150353667,"number":3529,"title":"Session.ScheduleTask and problems when task is not scheduled, but executed directly","user":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-22T12:18:45Z","updated_at":"2016-04-22T12:47:42Z","closed_at":null,"body":"In  a couple of different issues now we found a problem with the current implementation of `Session.ScheduleTask` and that is that if the session that is scheduled belongs to the same scheduler as the current running one, the task is not scheduled, but executed directly and there is no way for the user to control this.\r\n\r\nIn #3522 this might lead to a deadlock in the administrator, due to parts of the administrator has it's own locks and in #3490 the current transaction is locked on the thread, so accessing a viewmodel attached with another transaction will fail in the case when the task is executed directly.\r\n\r\nWe need to change this API so it either always schedules the task or add a possiblity to force a task to be scheduled.\r\n\r\n/cc @alemoi "},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/213413528","html_url":"https://github.com/Starcounter/Starcounter/issues/3529#issuecomment-213413528","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3529","id":213413528,"user":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T12:47:42Z","updated_at":"2016-04-22T12:47:42Z","body":"Well I don't think in the issues that were referenced that it would be possible. When called from commithooks and as the administrator is implemented with multiple threads accessing it, async access to sessions is required I think. \r\n\r\nActually, I think `Session.Use` should maybe not be public either and when you need to do something in a session you have to schedule a task for it since it needs to be run on the correct scheduler."}}