{"action":"created","issue":{"url":"https://api.github.com/repos/moqui/moqui-framework/issues/219","repository_url":"https://api.github.com/repos/moqui/moqui-framework","labels_url":"https://api.github.com/repos/moqui/moqui-framework/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/moqui/moqui-framework/issues/219/comments","events_url":"https://api.github.com/repos/moqui/moqui-framework/issues/219/events","html_url":"https://github.com/moqui/moqui-framework/issues/219","id":234403017,"number":219,"title":"Locking related issue using Postgresql","user":{"login":"jenshp","id":13221916,"avatar_url":"https://avatars2.githubusercontent.com/u/13221916?v=3","gravatar_id":"","url":"https://api.github.com/users/jenshp","html_url":"https://github.com/jenshp","followers_url":"https://api.github.com/users/jenshp/followers","following_url":"https://api.github.com/users/jenshp/following{/other_user}","gists_url":"https://api.github.com/users/jenshp/gists{/gist_id}","starred_url":"https://api.github.com/users/jenshp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenshp/subscriptions","organizations_url":"https://api.github.com/users/jenshp/orgs","repos_url":"https://api.github.com/users/jenshp/repos","events_url":"https://api.github.com/users/jenshp/events{/privacy}","received_events_url":"https://api.github.com/users/jenshp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-06-08T03:39:06Z","updated_at":"2017-06-08T13:35:43Z","closed_at":"2017-06-08T05:22:10Z","body":"I have seen an issue a couple of times on a production server, where (normally after having updated entity changes using the datasource.@startup-add-missing=\"true\" configuration) a kind of a deadlock occurs on the moqui.security.UserLoginHistory entity when logging in successfully. The result is that the webroot screen does not get rendered, and the request fails when the Bitronix Transaction times out after a minute.\r\n\r\nIt is not a real deadlock, but one new transaction performing a creation is being blocked by the \"current\" transaction after performing a find on the same entity (UserLoginHistory). In postgres, the latter is in \"idle in transaction\" state.\r\n\r\nI have been able to avoid this problem by changing the creation of the entity record in an asynchronous call rather than a synchronous one (see attached patch [async.txt](https://github.com/moqui/moqui-framework/files/1059875/async.txt)\r\n), but I am not sure that is the right solution.\r\n\r\nThis problem is not easily reproducible (it does not happen when I re-create the same database via pg_dump/pg_restore and using the same code base on another machine), but has happened a few times now. And once it happens on this machine, it begins to fail consistently on every login attempt for all tested users. Restarting tomcat and postgresql also does not work, but on some occasions rebooting the server made \"things work\" for a couple of minutes, but afterwards the locking issue re-emerges. Erasing cookies does not seem to avoid it either."},"comment":{"url":"https://api.github.com/repos/moqui/moqui-framework/issues/comments/307105155","html_url":"https://github.com/moqui/moqui-framework/issues/219#issuecomment-307105155","issue_url":"https://api.github.com/repos/moqui/moqui-framework/issues/219","id":307105155,"user":{"login":"jenshp","id":13221916,"avatar_url":"https://avatars2.githubusercontent.com/u/13221916?v=3","gravatar_id":"","url":"https://api.github.com/users/jenshp","html_url":"https://github.com/jenshp","followers_url":"https://api.github.com/users/jenshp/followers","following_url":"https://api.github.com/users/jenshp/following{/other_user}","gists_url":"https://api.github.com/users/jenshp/gists{/gist_id}","starred_url":"https://api.github.com/users/jenshp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenshp/subscriptions","organizations_url":"https://api.github.com/users/jenshp/orgs","repos_url":"https://api.github.com/users/jenshp/repos","events_url":"https://api.github.com/users/jenshp/events{/privacy}","received_events_url":"https://api.github.com/users/jenshp/received_events","type":"User","site_admin":false},"created_at":"2017-06-08T13:35:43Z","updated_at":"2017-06-08T13:35:43Z","body":"Just to complete the information, yes, the patch included in my post works, the record gets created and no error messages appear in the log. As for the location of the error, the symptoms are that the browser keeps waiting and there is nothing about it in the logs, it just \"gets stuck\" for a minute and then fails without any output to the browser. Checking the logs, after the transaction timeout you see only that fact and no possible cause (see [locking_log.txt](https://github.com/moqui/moqui-framework/files/1061106/locking_log.txt)).\r\nThis happened with PostgreSQL 9.2.18, using the default (read commited) transaction isolation level. While it happened, the only active operations were both, the select (in \"idle in transaction\" state and the insert (waiting for the lock held by the select) on the UserLoginHistory table.\r\nI will update now and come back if it happens again, thanks!"}}
{"actor":{"display_login":"jenshp"}}