Skip to content

Javers fails under load in distributed applications #657

Description

@gbondarchuk9

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'.

We use MySQL database, and Spring integration module.

Seems like the following situation occurs:

  1. On the first application instance we called javers.commit(...) in transaction - it retrieved max commit_id from database and then increased it.
  2. On the second application instance we also called javers.commit(...) in another transaction - it retrieved the same max commit_id as in step Initial diff #1 and also increased it by one. (first transaction is not committed yet)
  3. First application instance committed transaction - data successfully saved to database.
  4. 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.

_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?

Full Stacktrace
stacktrace.txt

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