8000 minigraf_close does not release an open cursor or fact log: reopening the path fails · Issue #10 · project-minigraf/minigraf-c · GitHub
[go: up one dir, main page]

Skip to content

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

Open

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

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0