13 Replies Latest reply on Jan 3, 2007 10:07 AM by Brian Stansberry

    Cache, missing entries

    Bartosz Baranowski Newbie

      I have encountered some problems with JBCache.
      I have transactional enviroment. changes are commited to cache upon tx commit phase - classes that implement TransactionalAction are executed.

      Hoever it misses some entries - cache doesnt retain entries it should upon concurrent tx running. Here is what is happening:

      1)Tx[1] reads data to cache and stores to local Map
      2)Tx[2] reads ......
      3)Tx[1] adds "ALA"
      4)Tx[1] adds "BEATA"
      5)Tx[2] removes "OLA" - last 3 operations are performed on local copies each tx stores in Map

      6)Tx[1] Commits - two new entries are added to Tx - they are present
      7)Tx[2] commits - one entry is removed

      Cache lacks "ALA" and "BEATA". In fact if our caching structure doesnt write all entries - to cache upon commit, those entries are missed too.

      on steps 1-2 TreeCache.getKeys(nodeName) is called, and for each key value from that node is retrieved, retrieed values are stored in local Map - which is not shared among tx, each has its local map.
      on steps 3-5 remove(key) and put(key,value) opearations are performed on local Maps - no cache operations are performed.
      in those steps TransactionAction's are added to SynchronizationHandler lists are added.
      On 6 tx.commit/TransactionManager.commit is called. actions stored in SynchHandler call TreeCache.put(nodeName,key,object) and remove(nodeName,key) (it could, if something was removed)
      - putting again and removing undeaded entries - whole copy of map is put into cache again, and some entries are removed
      On 7 is the same

      On steps 6-7 if whole local Map is not put into cache it lacks those entries which has not been put again. I mean if only updated, added entries are put in cache, all other are not retained.
      Is this expected behaviour? I have used jbcache 1.2 or 1.3 and newest version. Isolation level is READ COMMITED, with 1.4 I have tried Optimisitc locking scheme.

      Any suggestions would be highly welcome.
      Kind regards