[Design of JBossCache] - Re: Custom data versions
by manik.surtani@jboss.com
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
17 years, 9 months
[Design of JBossCache] - Re: Custom data versions
by bstansberry@jboss.com
That sounds fine to me. In the Hibernate integration most (I think all) calls involve a long tree of structural nodes with a single "data" node at the bottom. Two different custom data versions, one for structural, one for the "data" node. It should be simple for me to implement an optimized Map for that use case; i.e. this approach shouldn't cost much and will eliminate a lot of hassles.
Do you want a Map, or perhaps an interface:
| public interface DataVersionProvider {
|
| DataVersion getDataVersion(Fqn fqn);
|
| }
|
| If that's the only call JBC is going to make, it would be much simpler to write an optimized version of that vs. Map, where to be correct I'd have to implement a bunch of operations that I don't think would be invoked.
|
| We could provide a simple helper impl that takes a Map in the constructor and delegates to Map.get(Fqn).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163664#4163664
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163664
17 years, 9 months