Skip to content

close() from a user function inside a write transaction's statement blocks #26

Open

Description

@adityamukho

Found while reviewing project-minigraf/minigraf#824 (read from code, not reproduced).

MiniGrafDb.close() rolls back every open WriteTransaction by locking each transaction's slot (slot.lock()). While a transaction's statement runs, WriteTransaction::execute holds that slot. A user function that calls db.close() from inside that statement therefore blocks the JS thread on a mutex its own thread holds: the process hangs.

Expected: close() from inside a statement does not hang. Either it refuses with INT-001 (as a re-entrant call into the transaction already does via try_lock), or it closes the database and the running transaction is finished as soon as its statement returns, with later calls failing with API-018.

Possible fix: in close(), use try_lock on each slot. On WouldBlock (only possible through re-entry, since there is one JS thread), either refuse with INT-001, or mark the slot to be rolled back when execute releases it.

Refs project-minigraf/minigraf#824

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