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

Update LockService.cs to fix "The read lock is being released without being held" error. Fix for #641, 1637, 1993, 2017 #2280

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

mathis1337
Copy link
Contributor

@mathis1337 mathis1337 commented Jan 25, 2023

Fix for:
#641, #1637, #1993, #2017

resolving issue of
"ClassName": "System.Threading.SynchronizationLockException",
"Message": "The read lock is being released without being held.",

Issue is that the ReaderWriterLockSlim can be released or not set if not needed and so the code as it stands will attempt to call ExitReadLock() and this will throw an unhandled exception error.

I've added and If statement check to ensure there is exactly a ReadLock and also put it in a try catch in the event the Read is released within the small fraction of time the exit is called, so the remaining execution of code can run as needed.

I suspect that this ReleaseTransaction method that is referenced is multiple places is being called, or its just the lock is released too soon, but this fixes that until a better solution can be implemented.

I Know other have had this issue, so it would be good to get the PR in or if there is a better place to resolve this let me know and I'll investigate.

resolving issue of 
"ClassName": "System.Threading.SynchronizationLockException",
"Message": "The read lock is being released without being held.",
@mathis1337 mathis1337 changed the title Update LockService.cs to fix "The read lock is being released without being held" error. Update LockService.cs to fix "The read lock is being released without being held" error. Fix for #641, 1637, 1993, 2017 Jan 25, 2023
@Pete-PlaytimeSolutions
Copy link

Is there any timeframe for when this fix will make it into the main branch?
It's a blocker for us using this library via the NUGET package, currently we are having to use a local fork just to apply this patch

@mbdavid mbdavid merged commit d6038bf into litedb-org:master Jul 20, 2023
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

Successfully merging this pull request may close these issues.

3 participants