gridgain / gridgain-old

268 stars 85 forks source link

Read-Through can't be rolled back #85

Open ghost opened 9 years ago

ghost commented 9 years ago

I'm running gridgain 6.1.9, I need to load some data from RDBMS to several caches in a transaction via read-through, I wrote a unit test, it doesn't work.

From http://atlassian.gridgain.com/wiki/display/GG619/Pluggable+Persistent+Storage , I found "All read-through and write-through operations will participate in overall cache transaction and will be committed or rolled back as a whole."

To my understanding, following scenario should work, steps:

  1. one record in DB, no any data in cache
  2. start a transaction
  3. cache.get(key), load data to cache via read-through
  4. rollback transaction
  5. no any data in cache again

Part of the testing code:

JotmJtaTxMgrLookup.beginTransaction();
logger.info("cache.get({}) before rollback, it should be loaded from DB", id);
gotEmployee = cache.get(id);
assertEquals(name, gotEmployee.getName());
Employee employee = new Employee(2L, "test2");
cache.put(2L, employee);
JotmJtaTxMgrLookup.rollbackTransaction();
assertNull(cache.get(2L)); // it's rolled back
logger.info("cache.get({}) after rollback, it should be loaded again from DB", id); // but it doesn't
gotEmployee = cache.get(id);
assertEquals(name, gotEmployee.getName());

I'll push the whole testing project to GitHub if it's necessary.