Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Entity fetched on thread A, is not being updated on next fetch with changes made by thread B. #84

@dijef

Description

@dijef

To reproduce the problem:

  1. Create and save using repository entity A on new thread (repo.save(new Entity)).
  2. Fetch entity A using findById to confirm its name is null on main thread.
  3. Using new thread modify name on entity A to some random string.
  4. Now perform on main thread findById and check the name of entity A.
  5. Name parameter is null, it does not contain changes done by other thread.
    It works if step 2. is not performed.

I spent some time debugging and discovered that calling close() till it's actually closed on database solves the problem (which makes sense according to example on http://orientdb.com/docs/3.1.x/java/Java-Multi-Threading.html); Debugging starts with OPartitionedDatabasePool class, where it uses PoolData class to understand value of acquireCount int. It looks like this value is increased more times that being decreased. Once for new transaction and once for operation; e.g. save() through AbstractOrientOperations class ( dbf.db() calls aquire method ). Because of that, close() after transaction is completed does nothing. So next fetch is using out-of-date copy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions