Skip to content

Sqlite connection close() should wait for the database to be closed #1452

Closed

Description

@andrewwhitehead

The current implementation of close() for SqliteConnection is basically a no-op, relying on the drop method to close the connection. However, the connection handle is also owned by the statement worker thread, and so it will not be dropped until that thread polls the statement command queue and finds it empty. In effect, this means that there can be a noticeable delay between awaiting close() and the database connection actually being closed – this means that it is not (consistently) safe to close the database and then immediately try to remove the database file.

It looks like some refactoring would be necessary to make this work as expected, perhaps using an async channel to await the actual drop of the connection handle.

Activity

  1. abonander commented on Sep 23, 2021

    @abonander
    Collaborator

    It wouldn't be that bad, just add another variant to the StatementWorkerCommand enum with a one-shot channel, then send a message on that channel after dropping conn in the thread.

  2. added
    db:sqlite
    on Sep 24, 2021
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

    db:sqlite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions