You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing around with sqlx for sqlite databases, and I'm running into issues with it not properly closing connections even when calling Pool::close() and dropping all connection handles. It leaves db-wal and db-shm temporary files in the working directory, and I end up with errors about the table being locked when attempting to load a database file again that's been improperly closed.
Here's a basic example that opens a database, executes a few queries, then exits - there'll be various temporary files left over once the program ends:
use sqlx::sqlite::SqlitePool;#[tokio::main]asyncfnmain() -> anyhow::Result<()>{let pool = SqlitePool::new("sqlite://test.db").await?;
sqlx::query("create table if not exists test (foo text);").execute(&pool).await?;
sqlx::query("insert into test (foo) values (?)").bind("bar").execute(&pool).await?;
pool.close().await;Ok(())}
I'm using sqlx 0.3.4 with features ["runtime-tokio", "macros", "sqlite"].
Do let me know if I'm just missing something obvious, but it doesn't seem so.
The text was updated successfully, but these errors were encountered:
Sorry that this his happening. Can you reproduce this without using the pool? To try and narrow this down. You can connect directly using SqliteConnection::connect.
#[tokio::main]asyncfnmain() -> sqlx::Result<()>{letmut conn = sqlx::SqliteConnection::connect("sqlite://test.db").await?;
sqlx::query("create table if not exists test (foo text);").execute(&mut conn).await?;
sqlx::query("insert into test (foo) values (?)").bind("bar").execute(&mut conn).await?;Ok(())}
After some investigating, I think that self.statement also needs to be dropped here, otherwise the connection is being closed before all statements have been finalized.
I'm playing around with sqlx for sqlite databases, and I'm running into issues with it not properly closing connections even when calling
Pool::close()
and dropping all connection handles. It leavesdb-wal
anddb-shm
temporary files in the working directory, and I end up with errors about the table being locked when attempting to load a database file again that's been improperly closed.Here's a basic example that opens a database, executes a few queries, then exits - there'll be various temporary files left over once the program ends:
I'm using sqlx 0.3.4 with features
["runtime-tokio", "macros", "sqlite"]
.Do let me know if I'm just missing something obvious, but it doesn't seem so.
The text was updated successfully, but these errors were encountered: