{"action":"created","issue":{"url":"https://api.github.com/repos/javers/javers/issues/657","repository_url":"https://api.github.com/repos/javers/javers","labels_url":"https://api.github.com/repos/javers/javers/issues/657/labels{/name}","comments_url":"https://api.github.com/repos/javers/javers/issues/657/comments","events_url":"https://api.github.com/repos/javers/javers/issues/657/events","html_url":"https://github.com/javers/javers/issues/657","id":311642189,"number":657,"title":"Javers fails under load in distributed applications","user":{"login":"gbondarchuk9","id":38107167,"avatar_url":"https://avatars3.githubusercontent.com/u/38107167?v=4","gravatar_id":"","url":"https://api.github.com/users/gbondarchuk9","html_url":"https://github.com/gbondarchuk9","followers_url":"https://api.github.com/users/gbondarchuk9/followers","following_url":"https://api.github.com/users/gbondarchuk9/following{/other_user}","gists_url":"https://api.github.com/users/gbondarchuk9/gists{/gist_id}","starred_url":"https://api.github.com/users/gbondarchuk9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbondarchuk9/subscriptions","organizations_url":"https://api.github.com/users/gbondarchuk9/orgs","repos_url":"https://api.github.com/users/gbondarchuk9/repos","events_url":"https://api.github.com/users/gbondarchuk9/events{/privacy}","received_events_url":"https://api.github.com/users/gbondarchuk9/received_events","type":"User","site_admin":false},"labels":[{"id":267300548,"url":"https://api.github.com/repos/javers/javers/labels/fixed","name":"fixed","color":"0052cc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":22,"created_at":"2018-04-05T14:48:07Z","updated_at":"2018-04-22T16:44:02Z","closed_at":"2018-04-20T13:53:44Z","author_association":"NONE","body":"Javers fails under load in **distributed** applications during commit: org.javers.common.exception.JaversException: CANT_SAVE_ALREADY_PERSISTED_COMMIT: can't save already persisted commit '37140.0'.\r\n\r\nWe use MySQL database, and Spring integration module.\r\n\r\nSeems like the following situation occurs:\r\n\r\n1. On the first application instance we called javers.commit(...) in transaction - it retrieved max commit_id from database and then increased it.\r\n2. On the second application instance we also called javers.commit(...) in another transaction - it retrieved the same max commit_id as in step #1 and also increased it by one. (first transaction is not committed yet)\r\n3. First application instance committed transaction - data successfully saved to database.\r\n4. Second application instance committed transaction - we got exception as above, as data with the same commit_id already exist in database after first transaction completion.\r\n\r\n_We saw that CommitIdGenerator contains both: SYNCHRONIZED_SEQUENCE and RANDOM (for distributed applications), but RANDOM generator is deprecated, do we have some alternative generator for distributed applications? What can we undertake to fix the issue?\r\n\r\n**Full Stacktrace**\r\n[stacktrace.txt](https://github.com/javers/javers/files/1880498/stacktrace.txt)"},"comment":{"url":"https://api.github.com/repos/javers/javers/issues/comments/383394994","html_url":"https://github.com/javers/javers/issues/657#issuecomment-383394994","issue_url":"https://api.github.com/repos/javers/javers/issues/657","id":383394994,"user":{"login":"gbondarchuk9","id":38107167,"avatar_url":"https://avatars3.githubusercontent.com/u/38107167?v=4","gravatar_id":"","url":"https://api.github.com/users/gbondarchuk9","html_url":"https://github.com/gbondarchuk9","followers_url":"https://api.github.com/users/gbondarchuk9/followers","following_url":"https://api.github.com/users/gbondarchuk9/following{/other_user}","gists_url":"https://api.github.com/users/gbondarchuk9/gists{/gist_id}","starred_url":"https://api.github.com/users/gbondarchuk9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbondarchuk9/subscriptions","organizations_url":"https://api.github.com/users/gbondarchuk9/orgs","repos_url":"https://api.github.com/users/gbondarchuk9/repos","events_url":"https://api.github.com/users/gbondarchuk9/events{/privacy}","received_events_url":"https://api.github.com/users/gbondarchuk9/received_events","type":"User","site_admin":false},"created_at":"2018-04-22T16:44:02Z","updated_at":"2018-04-22T16:44:02Z","author_association":"NONE","body":"I've added a test - https://github.com/gbondarchuk9/javers/commit/75467e0346c264a4ebf95cda1a108ae6ee6c8eb0, but it works. Will try to find a way to get it failed.\r\n\r\nWhat I do is: execute two commits inside one transaction (just one by one):\r\n- start transaction\r\n- javers.commit(author, entity, properties)\r\n- entity = change(entity) //change some entity fields\r\n- javers.commit(author, entity, properties)\r\n- commit transaction - it produces two records in jv_shapshot table and two records in jv_commit table (commit date values are identical)\r\n- then query for shadows: it returns only one shadow related to the second commit.\r\n\r\nEither I modify one of commit dates by second (+/-), or do the same step as above under SEQUENCE generator - it works fine.\r\n"}}
{"actor":{"display_login":"gbondarchuk9"}}