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] Current transaction contains open cursors. Close cursors before run Commit() in 5.0.19 #2461

Closed
dethknite opened this issue Mar 25, 2024 · 2 comments
Labels

Comments

@dethknite
Copy link

dethknite commented Mar 25, 2024

Version: LiteDB v5.0.19

Describe the bug
When processing through records to delete oldest, the following error is thrown:
Current transaction contains open cursors. Close cursors before run Commit()

Code to Reproduce

using (var db = new LiteDatabase(connSharedReadWrite))
{
    // .... set min/max records and step
    long min=0, max=10000000;
    int step = 10000;
    long recordsToDelete = 250000;
    long recordsDeleted = 0;

    // Process
    while (min < max)
    {
        //Process each step..
        foreach (DbObject item in col.Find(Query.All("ObjectDateTime", Query.Ascending)).Skip(0).Take(step).ToArray())
        {
            //Delete Record
            col.Delete(BsonMapper.Global.Serialize(item)["_id"]);

            recordsDeleted+=1;
            if (recordsDeleted >= recordsToDelete)
                break;
        }

        if (recordsDeleted >= recordsToDelete)
            break;

        //Update position
        min += step;
    }
}

Expected behavior
In v5.018 and lower, this functions as expected and deletes records.

@dethknite dethknite added the bug label Mar 25, 2024
@dethknite dethknite changed the title Current transaction contains open cursors. Close cursors before run Commit() in 5.0.19 [BUG] Current transaction contains open cursors. Close cursors before run Commit() in 5.0.19 Mar 25, 2024
@alexbereznikov
Copy link

alexbereznikov commented Mar 27, 2024

It looks like the same issue as in #2440 and #2435 , #2436 change fixed it for us

@JKamsker
Copy link
Collaborator

JKamsker commented Jun 5, 2024

Thank you for reporting this issue.

This issue has been resolved in the latest version of LiteDB.
Please update to the latest version of LiteDB to resolve this issue.
If the issue persists, please let us know.

@JKamsker JKamsker closed this as completed Jun 5, 2024
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