-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clustered environments Javers will incorrectly version records. #877
Comments
Seems that in clustered environments Javers should not use the Sequence Allocation trick, see https://github.com/javers/javers/blob/master/javers-persistence-sql/src/main/java/org/javers/repository/sql/session/Sequence.java#L12 Without the Sequence Allocation trick, primary keys ordering would be guaranteed by the database sequence. Sequence nextval call should be inlined in the |
inlined sequence nextval for jv_snapshot inserts
fixed in 5.7.1 |
Hi Bartosz, Just some general questions about this fix. It appears that you were multiplying the sequence number by a hundred as some sort of caching mechanism. e.g. Meaning I need to promote the JV_SNAPSHOT_PK_SEQ to SNAPSHOT_PK + 1? Are there any other Sequences I need to promote? Your change appears to be to very generic code, so I assume you changed all the sequences to use this behaviour? While I manage the JV tables/sequences (I've disabled schema management), I didn't see code in the commit that would automatically promote other sequences in the managed cased. Thanks, Duane |
Looks like the bigger problem is in this line in
So when SEQUENCE_ALLOCATION trick is discontinued, db sequences should be multiplied by 100. I need to check it. For now, version 5.7.1 has to be withdrawn. |
crud *100 fix to keep backward compatibility
In the new fix, |
fixed in 5.7.2 |
Issue:
User on node 1 inserts a record (version 1, initial snapshot is inserted).
User on node 2 updates the record (version 2, update is inserted).
User on node 3 updates the record (version 2, update is inserted). Note this is incorrect is should be version 3.
JV_SNAPSHOT table example.
What is should look like:
Problem Code (I think):
https://github.com/javers/javers/blob/master/javers-persistence-sql/src/main/java/org/javers/repository/sql/finders/CdoSnapshotFinder.java#L104
The logic seems to be select the max pk and then find the version number from that.
I think here you are assuming the numbers are always representative of insert order. But there is many cases where this would not be true. In this case since the first node that did the insert was ahead in snapshot_pk, subsequent inserts are always ignored for selection as the latest version.
The text was updated successfully, but these errors were encountered: