CSharpTest.Net.Collections icon indicating copy to clipboard operation
CSharpTest.Net.Collections copied to clipboard

BPlusTree: Meaningless AssertionFailedException if the lock was not acquired

Open csharptest opened this issue 10 years ago • 1 comments

If the CallLevel lock cannot be acquired due to timeout then the Assertion is triggered. In this case it would be better to throw some specific exception derived from TimeoutException, so the user code can react appropriately.

There are a couple of lines in the constructor of RootLock:

_locked = _exclusive ? _tree._selfLock.TryWrite(tree._options.LockTimeout) :   _tree._selfLock.TryRead(tree._options.LockTimeout);
Assert(_locked);

Instead I suggest to do this:

_locked = _exclusive ? _tree._selfLock.TryWrite(tree._options.LockTimeout) : _tree._selfLock.TryRead(tree._options.LockTimeout);
if (!_locked)
    throw new BPlusTreeTimeoutException("...");

csharptest avatar Jan 29 '15 17:01 csharptest

Fixed on /dev

csharptest avatar Feb 23 '15 00:02 csharptest