Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BPlusTree: Meaningless AssertionFailedException if the lock was not acquired #6

Open
csharptest opened this issue Jan 29, 2015 · 1 comment

Comments

@csharptest
Copy link
Owner

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
Copy link
Owner Author

Fixed on /dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant