{"action":"created","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3744","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3744/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3744/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3744/events","html_url":"https://github.com/orientechnologies/orientdb/pull/3744","id":60577611,"number":3744,"title":"Issue seq","user":{"login":"matanshukry","id":5613042,"avatar_url":"https://avatars.githubusercontent.com/u/5613042?v=3","gravatar_id":"","url":"https://api.github.com/users/matanshukry","html_url":"https://github.com/matanshukry","followers_url":"https://api.github.com/users/matanshukry/followers","following_url":"https://api.github.com/users/matanshukry/following{/other_user}","gists_url":"https://api.github.com/users/matanshukry/gists{/gist_id}","starred_url":"https://api.github.com/users/matanshukry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matanshukry/subscriptions","organizations_url":"https://api.github.com/users/matanshukry/orgs","repos_url":"https://api.github.com/users/matanshukry/repos","events_url":"https://api.github.com/users/matanshukry/events{/privacy}","received_events_url":"https://api.github.com/users/matanshukry/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/approved%20feature","name":"approved feature","color":"fbca04"},{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/contributor%20friendly","name":"contributor friendly","color":"009800"},{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"lvca","id":312606,"avatar_url":"https://avatars.githubusercontent.com/u/312606?v=3","gravatar_id":"","url":"https://api.github.com/users/lvca","html_url":"https://github.com/lvca","followers_url":"https://api.github.com/users/lvca/followers","following_url":"https://api.github.com/users/lvca/following{/other_user}","gists_url":"https://api.github.com/users/lvca/gists{/gist_id}","starred_url":"https://api.github.com/users/lvca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvca/subscriptions","organizations_url":"https://api.github.com/users/lvca/orgs","repos_url":"https://api.github.com/users/lvca/repos","events_url":"https://api.github.com/users/lvca/events{/privacy}","received_events_url":"https://api.github.com/users/lvca/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/orientechnologies/orientdb/milestones/17","html_url":"https://github.com/orientechnologies/orientdb/milestones/2.2","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/milestones/17/labels","id":613160,"number":17,"title":"2.2","description":"","creator":{"login":"lvca","id":312606,"avatar_url":"https://avatars.githubusercontent.com/u/312606?v=3","gravatar_id":"","url":"https://api.github.com/users/lvca","html_url":"https://github.com/lvca","followers_url":"https://api.github.com/users/lvca/followers","following_url":"https://api.github.com/users/lvca/following{/other_user}","gists_url":"https://api.github.com/users/lvca/gists{/gist_id}","starred_url":"https://api.github.com/users/lvca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvca/subscriptions","organizations_url":"https://api.github.com/users/lvca/orgs","repos_url":"https://api.github.com/users/lvca/repos","events_url":"https://api.github.com/users/lvca/events{/privacy}","received_events_url":"https://api.github.com/users/lvca/received_events","type":"User","site_admin":false},"open_issues":243,"closed_issues":7,"state":"open","created_at":"2014-03-28T13:17:36Z","updated_at":"2015-08-04T11:26:04Z","due_on":"2015-09-21T22:00:00Z","closed_at":null},"comments":24,"created_at":"2015-03-10T22:08:13Z","updated_at":"2015-08-04T18:59:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/orientechnologies/orientdb/pulls/3744","html_url":"https://github.com/orientechnologies/orientdb/pull/3744","diff_url":"https://github.com/orientechnologies/orientdb/pull/3744.diff","patch_url":"https://github.com/orientechnologies/orientdb/pull/3744.patch"},"body":"## User perspective \r\n### Usage\r\n\r\n#### Create a sequence\r\n    CREATE SEQUENCE <sequence> [TYPE <CACHED|ORDERED>] [START <value>] [INCREMENT <value>] [CACHE <value>]\r\n\r\nSequence types:\r\n * Ordered: Each call to .next() will result in a new value.\r\n * Cached: The sequence will cache N items on each node, thus improving the performance if many .next() calls are required. However, this may create holes.\r\n\r\n#### Drop a sequence\r\n    DROP SEQUENCE <sequence>\r\n\r\n#### Using a sequence\r\n    SELECT #<sequence>.<function>\r\nPossible functions:\r\n * next() - retrieve the next value.\r\n * current() - get the current value\r\n * reset() - reset the sequence value to it's initial value.\r\n\r\n### Notes \r\n\r\n#### Prefix\r\nI decided to use the hash sign(#) prefix for sequences, although that is easy to replace. The reason to use any sign was due to code architecture, however in my opinion it is also the better option; When not using any prefix, it can collide with table columns.\r\n\r\n#### Distributed\r\nDistributed sequences are not 100% working now. They will most probably work, just be careful not to use them too much (although i'm hoping we can finish the work with distributed sequences until the next release).\r\n\r\n## Code perspective \r\n\r\n### Test\r\nI added two test cases:\r\n* SequenceTest: Check a sequence simply \"works\". That is, calling .next() return next value, .current() return the current, and reset() resets the value. Simple.\r\n* Distributed test: This test case actually test 3 issues:\r\n ** Ordered sequence: check two ordered sequence, under simple load, will generate ordered values.\r\n ** Cached sequence: Check two cached sequences, with a specific cache value, will generate values with \r\nrange same as cache value (showing that one of the sequences cached a range of values)\r\n ** Parallel Sync: Attempt to create multiple (2) threads, where each thread will use a different node (and databases, as according to multi-threading rules in orientdb), and generate unique N(100) values, each. The result should be 2*N(200) unique values.\r\n\r\nNotes:\r\n* The test it self cause _many_ OConcurrentModificationException, which are printed to the console. This is valid, and the test does succeed.\r\n* The parallel sync test is currently _not_ working. I am still working on it, although it seems like an edge case, and a regular normal-load of usage of the sequences, even distributed, shouldn't cause this problem.\r\n In order to pass the test though, it has a flag which is set to false, hence not testing this specific test (parallel sync) at all.\r\nI am not entirely sure what the problem is, but there seem to be more than one:\r\n* The initial problem was the one I fixed in this PR: #3738 \r\n* The second problem was with OConcurrentModificationException, which seems to be now fixed (fixed recently by lvca)\r\n* There still seems to be a problem now, where when an update to a field is happening distributed, the results are conflicted: one node return the same version as sent, and the other a higher one. I am still looking into it, and will post as soon as possible.\r\n\r\nAlthough the distributed part of sequences is not complete, I decided to still open this PR in case someone more experienced with the project might shed some light on the distributed errors."},"comment":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/comments/127718668","html_url":"https://github.com/orientechnologies/orientdb/pull/3744#issuecomment-127718668","issue_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3744","id":127718668,"user":{"login":"matanshukry","id":5613042,"avatar_url":"https://avatars.githubusercontent.com/u/5613042?v=3","gravatar_id":"","url":"https://api.github.com/users/matanshukry","html_url":"https://github.com/matanshukry","followers_url":"https://api.github.com/users/matanshukry/followers","following_url":"https://api.github.com/users/matanshukry/following{/other_user}","gists_url":"https://api.github.com/users/matanshukry/gists{/gist_id}","starred_url":"https://api.github.com/users/matanshukry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matanshukry/subscriptions","organizations_url":"https://api.github.com/users/matanshukry/orgs","repos_url":"https://api.github.com/users/matanshukry/repos","events_url":"https://api.github.com/users/matanshukry/events{/privacy}","received_events_url":"https://api.github.com/users/matanshukry/received_events","type":"User","site_admin":false},"created_at":"2015-08-04T18:59:49Z","updated_at":"2015-08-04T18:59:49Z","body":"That could be a good feature, but I feel like the optimistic approach (MVCC) should work.\r\n\r\nAlthough your changes to the code would work, I see no reason why we need to add a pause to make it work; It sound like an internal flaw.\r\n\r\nI tried increasing the internal try and catching it too, by the way; it wasn't enough."}}