I think before accquiring a remote lock, the current implementation will still try to acquire a local lock, is that correct?
Yes, a local lock is still acquired.
Could we have an option to entirely disable the local lock? This will be very helpful to avoid deadlock(local vs. remote) when there's a heavy concurrent write load on a specific key.
I think deadlock detection should be able to determine such a deadlock. Also if you the keyAffinityService to enforce key's locality you won't hit this problem (this is described here: http://community.jboss.org/wiki/LockingandConcurrency#Locking_a_single_remote_node) . On the other hand I think this is a interesting idea and I see utility for it. Any more comments on this?
KeyAffinityService looks nice, but I'm not sure we can use it now because currently the key we are using is generated by database. Deadlock dection can help, yet it will be better if we could avoid the deadlock.