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

Application crash at DropCollection #2460

Open
InesCodMon opened this issue Mar 25, 2024 · 2 comments
Open

Application crash at DropCollection #2460

InesCodMon opened this issue Mar 25, 2024 · 2 comments
Labels

Comments

@InesCodMon
Copy link

Version
v5.0.18 and v5.0.19 /MacOS/.NET Standard 2.0

Describe the bug
I want to clean up the database (remove all collections and their content). But an error occurs when DropCollection is called the first time.

Code to Reproduce
public void CleanupDatabase()
{
IEnumerable listOfCollections = _db.GetCollectionNames();
foreach (string item in listOfCollections)
{
Console.WriteLine("COLLECTION" + item.ToString());
_db.DropCollection(item);
}
}

Expected behavior
All collections should be removed. The above code is expected to work the same as it does in version v5.0.17.

Screenshots/Stacktrace
The below error occurs when the DropCollection method is called.

LiteDB.LiteException: The current thread already contains an open transaction. Use the Commit/Rollback method to release the previous transaction.
at LiteDB.Engine.LiteEngine.DropCollection (System.String name) [0x0003e] in :0
at LiteDB.LiteDatabase.DropCollection (System.String name) [0x00013] in :0

@InesCodMon InesCodMon added the bug label Mar 25, 2024
@fabiorme
Copy link

I encountered the same error while migrating from v5.0.17 to v5.0.19

LiteDB.LiteException: The current thread already contains an open transaction. Use the Commit/Rollback method to release the previous transaction.
at LiteDB.Engine.LiteEngine.DropCollection (System.String name) [0x0003e] in <757508dac4404cdea3f8947f089148e1>:0
at LiteDB.LiteDatabase.DropCollection (System.String name) [0x00013] in <757508dac4404cdea3f8947f089148e1>:0

I tried both Commit and Rollback before performing the drop, but it didn't work. I think for now I'll revert back to version 17.

@GreenIreland
Copy link

I encountered the same error while migrating from v5.0.17 to v5.0.19

Same.

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

3 participants