Skip to content

Repeatedly creating and dropping an index grows the database file by about 16 KB per cycle #209

Open

Description

@mrdevrobot

Version: main (efacaf4).

What happens

10,000 cycles of CreateIndexAsync + DropIndexAsync on a typed collection grow the file from about 2 MB to about 166 MB. Found while testing #196; it happens on main the same way, so it isn't the metadata chain.

CollectionIndexManager.DropIndex frees the tree with FreeAllPages (CollectionIndexManager.cs:282-292). Two likely causes, not yet confirmed:

Repro sketch

for (int i = 0; i < 10_000; i++)
{
    await db.PeopleV2.CreateIndexAsync(p => p.Name, "idx_tmp");
    await db.PeopleV2.DropIndexAsync("idx_tmp");
}
// compare file size before and after; then CheckpointAsync() and compare again

Expected

After a checkpoint, the pages of the dropped indexes are reused and the file stops growing. If the growth disappears after a checkpoint, it's the deferred-free queue and only needs a size or count trigger for the checkpoint; if it doesn't, pages are leaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/indexingB-Tree and secondary indexes, index lifecyclebugSomething isn't workingpackage/coreAffects BLite.Corepriority/P2Should be in the next minor release if time allowsseverity/mediumSpace leak, inconsistency or failure in a narrow scenario

    Type

    No type

    Projects

    • Status
      Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions