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

Check if the read lock is held before exiting #1639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LiteDB.Tests/Engine/ParallelQuery_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace LiteDB.Tests.Engine
{
public class ParallelQuery_Tests
{
[Fact(Skip = "Must fix parallel query fetch")]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voila! the parallel query works with this change.

[Fact]
public void Query_Parallel()
{
using(var db = new LiteDatabase(new MemoryStream()))
Expand Down
3 changes: 2 additions & 1 deletion LiteDB/Engine/Services/LockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void ExitTransaction()
// if current thread are in reserved mode, do not exit transaction (will be exit from ExitExclusive)
if (_transaction.IsWriteLockHeld) return;

_transaction.ExitReadLock();
if (_transaction.IsReadLockHeld)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check before exiting, otherwise ExitReadLock throws System.Threading.SynchronizationLockException:The read lock is being released without being held

_transaction.ExitReadLock();
}

/// <summary>
Expand Down