A glorious end. The transactional stuff solved the problem.
Well, mostly... The evolved code is below. But even with transactions doing their duty i
still noticed gaps in the data. I had to put sleeps into the loops because when all
threads run at full speed a literal clusterf*** ensues... rollback and timeout exceptions
go flying everywhere.
But with the delays in there, things calm down nicely. Even still, although the results
are reassuring, they are not exact. The below code should end up with a final count of
1000, but instead twice it ended with 999. I assumed it was a bug, but in the output i
noticed that this message was written twice: "Put 91". This means something
slipped between the cluster cracks somewhere.
I don't need to do updates as quickly as i coded for in these tests - i was just
testing the boundaries. And indeed, these results are good enough for my present purposes.
Overall i think it's great stuff, but it would seem that there may still be small
holes in the MVCC code.
public static void main(String[] args) throws Exception {
| Cache<String, Integer> cache = new DefaultCacheFactory<String,
Integer>().createCache("conf/cache.xml");
|
| // Wait for other members.
| System.out.println("Waiting for other members...");
| while (cache.getMembers().size() < 4)
| Thread.sleep(50);
|
| System.out.println("Running...");
|
| TransactionManager txm = new
DummyTransactionManagerLookup().getTransactionManager();
|
| Random random = new Random();
| int versioningFaults = 0;
| int rollbackFaults = 0;
| int suspectFaults = 0;
| int timeoutFaults = 0;
| for (int i=0; i<50; i++) {
| Thread.sleep(random.nextInt(2000));
|
| // Modify the cache
| while (true) {
| try {
| txm.begin();
|
| Integer count = cache.getRoot().get("key");
| if (count == null)
| count = 0;
| count++;
|
| while (true) {
| try {
| cache.getRoot().put("key", count);
| System.out.println("Put "+ count);
| break;
| }
| catch (SuspectException e) {
| suspectFaults++;
| }
| catch (TimeoutException e) {
| timeoutFaults++;
| }
| }
|
| txm.commit();
| break;
| }
| catch (DataVersioningException e) {
| txm.rollback();
| versioningFaults++;
| }
| catch (RollbackException e) {
| rollbackFaults++;
| }
| }
| }
|
| System.out.println("Final count: "+
cache.getRoot().get("key"));
| System.out.println("Versioning faults: "+ versioningFaults);
| System.out.println("Rollback faults: "+ rollbackFaults);
| System.out.println("Suspect faults: "+ suspectFaults);
| System.out.println("Timeout faults: "+ timeoutFaults);
|
| cache.stop();
| cache.destroy();
| }
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4260670#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...