[jboss-user] [JBoss Cache Users] - Re: how to lock a node for update?

alllle do-not-reply at jboss.com
Wed Sep 23 14:38:16 EDT 2009


"manik.surtani at jboss.com" wrote : You can force write locks for a read.  There is an Option for this (see the Options API). When used with MVCC, this gives you an exclusive (write) lock, when when you are reading.  And when combined with a transaction, this means you hold the write lock until the tx completes.

Thanks for the help.

I assume you are referring to some thing like this (from the doc):

  |  // first start a transaction
  |  cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
  |  Node n = cache.getNode(Fqn.fromString("/a/b/c"));
  |  // make changes to the node
  |  // commit transaction        
  | 

I wonder if you can explain it in a little more detail. I need some clarification to my confusions:
- when is the lock obtained? is it, like the write lock, at the time when the transaction commits or it is at the time when the read happens?
- What is considered as a "read"? I mean, does cache.getNode() considered a "read", or only when I do a subsequent node.get("key") is when the lock obtained?
- With "REPEATABLE_READ" isolation, is the "write skew" still a problem? - I think it's not but I'd like to get a confirmation from you.
- What is the scope of the current "InvocationContext"? Is it within the current transaction, or current thread, or something else?



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4256728#4256728

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4256728



More information about the jboss-user mailing list