[jboss-dev-forums] [Design of JBossCache] - Re: Custom data versions
manik.surtani@jboss.com
do-not-reply at jboss.com
Thu Jul 10 13:03:09 EDT 2008
Now with MVCC I really don't have a need for data versions internally - the only reason I still use DataVersions is to support custom data versions from Hibernate.
I was thinking, maybe there is a way we can achieve the same consistency without the use of data versions?
Consider:
1. Server 1 wants to write V2
2. Server 2 wants to read, checks the cache, nothing there, and then decides to go to the DB
3. Server 2 reads V1 from DB
4. Server 1 writes V2 in DB
5. Server 1 puts V2 in cache, invalidates remote caches
6. Server 2 puts V1 in cache, invalidates remote caches
And this is the problem, right?
What if an additional step is introduced:
2.5. Server 2 knows it needs to go to the DB so it starts an isolated tx, does another cache.get() with a forceWriteLock option.
So now Server1's invalidate message will wait until server2 has read v1 and put it in the cache, then the invalidate message will remove it which is correct.
Since MVCC allows for non-blocking reads, Server2 will have to check the state of the cache again after acquiring the WL though to see if it still needs to go to the DB incase another reader had read from the DB and updated the cache. (Reminiscent of DCL, thankfully the same ills don't apply here).
What do you guys think?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163671#4163671
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163671
More information about the jboss-dev-forums
mailing list