orientechnologies / spring-data-orientdb

OrientDB implementation for SpringData

Home Page:http://forum.springsource.org/showthread.php?99627-OrientDB-support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dijef opened this issue · comments

commented

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.