[BUG] FindById throws SynchronizationLockException: The read lock is being released without being held.
See original GitHub issueVersion 5.0.5
Describe the bug FindById sporadically throws System.Threading.SynchronizationLockException: “The read lock is being released without being held.”
Code to Reproduce Here how I use FindById -it is hard to reproduce the issue though
public T FindById<T>(int id)
{
var data = database.GetCollection<T>(typeof(T).Name).FindById(new BsonValue(id));
if (Equals(data, default(T)))
{
throw new InvalidOperationException($"Cannot find {typeof(T).Name} with id {id}");
}
return data;
}
Expected behavior No exceptions.
Screenshots/Stacktrace
“ClassName”: “System.Threading.SynchronizationLockException”,
“Message”: “The read lock is being released without being held.”,
“Data”: null,
“InnerException”: null,
“HelpURL”: null,
“StackTraceString”: " at System.Threading.ReaderWriterLockSlim.ExitReadLock()\r\n at LiteDB.Engine.TransactionMonitor.ReleaseTransaction(TransactionService transaction)\r\n at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)\r\n at LiteDB.Engine.LiteEngine.Query(String collection, Query query)\r\n at LiteDB.LiteQueryable1.<ToDocuments>d__26.MoveNext()\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()\r\n at
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:11
Top GitHub Comments
@lbnascimento Could you please review the pull request?
Just an update, The suggested fix by @huyhu solved my issues, but have had to fork the code base, hopefully temporarily 😃