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

[BUG] Rebuild() throws System.Threading.SynchronizationLockException #1551

Closed
JensSchadron opened this issue Mar 9, 2020 · 2 comments
Closed
Labels

Comments

@JensSchadron
Copy link
Contributor

Version
Which LiteDB version/OS/.NET framework version are you using. (REQUIRED)
Latest version from master, commit 6c0886e

Describe the bug
A clear and concise description of what the bug is.
Calling Rebuild() on a LiteDatabase instance results in a SynchronizationLockException.

Code to Reproduce
Write a small snippet to isolate your bug and could be possible to our team test. (REQUIRED)

var db = new LiteDatabase(new ConnectionString("Lite.db")
{
    Connection = ConnectionType.Direct
});

try
{
    db.Rebuild();
    Console.WriteLine("Rebuild succeeded.");
}
catch (Exception e)
{
    Console.WriteLine(e);
    throw;
}

Expected behavior
A clear and concise description of what you expected to happen.
Should rebuild the datafile without throwing an exception.

Screenshots/Stacktrace
If applicable, add screenshots/stacktrace

System.Threading.SynchronizationLockException: The write lock is being released without being held.
   at System.Threading.ReaderWriterLockSlim.ExitWriteLock()
   at LiteDB.Engine.LockService.ExitExclusive() in /Users/jens/Documents/Projects/LiteDB/LiteDB/Engine/Services/LockService.cs:line 140
   at LiteDB.Engine.LiteEngine.Rebuild(RebuildOptions options) in /Users/jens/Documents/Projects/LiteDB/LiteDB/Engine/Engine/Rebuild.cs:line 87
   at LiteDB.LiteDatabase.Rebuild(RebuildOptions options) in /Users/jens/Documents/Projects/LiteDB/LiteDB/Client/Database/LiteDatabase.cs:line 273
   at LiteDB.Sandbox.Program.Main(String[] args) in /Users/jens/Documents/Projects/LiteDB/LiteDB.Sandbox/Program.cs:line 23

Additional context
Add any other context about the problem here.
As far as my testing goes, the bug was introduced in commit 3bda0f0 as my code snippet was still working when I was testing with commit 8c956c5

@lbnascimento
Copy link
Contributor

@JensSchadron Could you test with the current master? The transaction model was entirely rewritten.

@JensSchadron
Copy link
Contributor Author

I'was following the progression of PR #1560 "live". But was going to close this ticket when it got merged into master.
That being the case, I'll close this ticket as it works just fine now.

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

No branches or pull requests

2 participants