Skip to content

minigraf_close does not release an open cursor or fact log: reopening the path fails #10

Done

Description

@adityamukho

Found while implementing prepared queries (project-minigraf/minigraf#181, spec §6). It's the same gap as project-minigraf/minigraf-node#17.

After minigraf_close(db), a MiniGrafCursor or MiniGrafFactLog from that handle that hasn't been freed still holds a core Snapshot, which keeps the storage (the in-process registration and the file lock) alive. minigraf_open of the same path returns NULL until the cursor or log is freed.

MiniGrafDb *db = minigraf_open(p);
minigraf_string_free(minigraf_execute(db, "(transact [[:a :n 1]])"));
minigraf_checkpoint(db);
MiniGrafCursor *c = minigraf_query(db, "(query [:find ?e :where [?e :n _]])");  /* or minigraf_fact_log */
minigraf_close(db);
minigraf_open(p);   /* NULL: still open in this process */

Prepared queries (#181) avoid this: minigraf_close empties every MiniGrafPrepared made from the handle. Cursors and fact logs could do the same (a weak list on MiniGrafDb; later next_batch returns NULL with no error), or the header could document that they must be freed before minigraf_close when the path will be reopened.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Oct 24, 2026
  2. added this to the v3.0.0 milestone on Nov 30, 2026
  3. added a commit that references this issue on Nov 30, 2026
  4. adityamukho commented on Nov 30, 2026

    @adityamukho
    ContributorAuthor

    Fixed in #22 (merged into v3).

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

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions