NHibernate expected locking behavior

Skip to first unread message

Adam Carasso

Apr 27, 2011, 8:04:16 PM4/27/11
to NHibernate Contrib - Development Group
I was wondering if someone could shed some light on how ICache.Lock is
expected to behave. I have looked myself but I am just not as
familiar with the contrib code as I should be and was not able to
easily find it by looking at the code. Perhaps one of you who is more
experienced than I could answer the following:

If a lock currently exist on a entity and I try to acquire that lock
with ICache.Lock (assuming locking in implemented) is the provider
expected to block on the lock call or just return failure. If it is
the latter I believe there is a rather dangerous bug in the NH
Velocity (App Fabric) cache provider even in the patched version. As
Velocity's (App Fabric's) lock operation is non blocking and simply
throws an exception when a lock is already acquired.

The following is from the App Fabric documentation for the
DataCache.GetAndLock() function:
Return Value

Returns Object matching the specified key parameter if the Object is
present and is not locked.
If the key does not exist, a DataCacheException object is thrown with
the ErrorCode set to KeyDoesNotExist. Create objects based on the
referenced key to resolve this error.

If the object is already locked by another cache client, a
DataCacheException object is thrown with the ErrorCode set to
ObjectLocked. The object will be inaccessible until it is unlocked by
the locking client.

Any Info would be hugely appreciated,
Adam Carasso
Reply all
Reply to author
0 new messages