Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andrewwhitehead opened this issue Sep 23, 2021 · 1 comment · Fixed by #1453
Closed

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

andrewwhitehead opened this issue Sep 23, 2021 · 1 comment · Fixed by #1453
Labels
db:sqlite Related to SQLite

Comments

@andrewwhitehead
Copy link
Contributor

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.

@abonander
Copy link
Collaborator

abonander commented Sep 23, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db:sqlite Related to SQLite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants