Skip to content

Clustered environments Javers will incorrectly version records. #877

@duane-staehli

Description

@duane-staehli

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.

snapshot_pk type version
5292412 UPDATE 2
5292604 UPDATE 2
5292701 INITIAL 1

What is should look like:

snapshot_pk type version
5292412 UPDATE 3
5292604 UPDATE 2
5292701 INITIAL 1

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions