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: CallLevel lock is never released in the case of exception #7

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

Comments

@csharptest
Copy link
Owner

There is a possibility that CallLevel lock would never be released.
And this is really happening if LockTimeout expires in NodeCache.

Here is the code in the constructor of RootLock:

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

If an exception is thrown in '_tree._storage.LockRoot(type)' then '_tree._selfLock' will never be released.
So the code should be enclosed by try..catch:

try
{
    Pin = _tree._storage.LockRoot(type);
}
catch
{
    if (_exclusive)
       _tree._selfLock.ReleaseWrite();
    else
       _tree._selfLock.ReleaseRead();
    throw;
}
@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