I'm using Jboss Tree Cache pojo version NAGA 3.0
How can I invoke an exception to see the behaviour of the writeSkewCheck?
I've seen several articles explaining the Phantom Read at a very high level, but down to an API user's level, how can I simulate a skewed write.
Say for example two threads within the same JVM do
Cache internalCache = getCache(); Node rootNode = internalCache.getRoot(); Node sequenceNode = rootNode.getChild(Fqn.fromString(SEQUENCE_FQN)); // READ Integer sequence = (Integer) sequenceNode.get(SEQUENCE_FQN); Thread.sleep(1000); // WRITE sequenceNode.put(SEQUENCE_FQN, sequence +1);
Alright, I've figured it out.
I just needed to wrap this piece of code in a transaction.
Even a dummyTransaction will do.
It ended up throwing a: org.jboss.cache.optimistic.DataVersioningException