Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Database starts returning HTTP status 500 after lots of inserts #714

Open
penberg opened this issue Oct 1, 2023 · 1 comment
Open

Database starts returning HTTP status 500 after lots of inserts #714

penberg opened this issue Oct 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@penberg
Copy link
Contributor

penberg commented Oct 1, 2023

I have two reports of the database starting to return HTTP status 500 after lots of inserts. One user reported that dropping the tables, creating them again and inserting the data fixed the issue, which suggest that the issue does not always happen when inserting lots of data.

@penberg penberg added the bug Something isn't working label Oct 1, 2023
@ultrabug
Copy link
Contributor

Oh so I'm not crazy and doing bad things on my side... lots of inserts in my case is usually > 100 😅 dunno if that's a lot 😁

simple dirty local code:

use libsql_client;

#[tokio::main]
async fn main() {
    let db = libsql_client::Client::from_env().await.unwrap();
    let _ = db.execute("drop table if exists example_users;").await.unwrap();
    let _ = db.execute("create table if not exists example_users (uid text primary key, email text);").await.unwrap();
    let rs = db.execute("select count(*) from example_users;").await.unwrap();
    println!("result {:?}", rs);
    for n in 0..150 {
        let stmt = format!("insert into example_users values ('uid {n}', 'email {n}');");
        // println!(". {}", stmt);
        let _ = db.execute(stmt).await;
    }
    let rs = db.execute("select count(*) from example_users;").await.unwrap();
    println!("result {:?}", rs);
}

will produce:

$ LIBSQL_CLIENT_URL=http://127.0.0.1:8080 cargo run
result ResultSet { columns: ["count (*)"], rows: [Row { values: [Integer { value: 0 }], value_map: {"count (*)": Integer { value: 0 }} }], rows_affected: 0, last_insert_rowid: None }
result ResultSet { columns: ["count (*)"], rows: [Row { values: [Integer { value: 140 }], value_map: {"count (*)": Integer { value: 140 }} }], rows_affected: 0, last_insert_rowid: None }

10 missing rows :(

sqld running (fresh build) and erroring:

config:
	- mode: standalone
	- database path: data.sqld
	- extensions path: <disabled>
	- listening for HTTP requests on: 127.0.0.1:8080
	- grpc_tls: no
2023-10-16T13:44:02.709804Z  INFO sqld: listening for incoming user HTTP connection on 127.0.0.1:8080
2023-10-16T13:44:02.709848Z  INFO sqld: listening for incoming user hrana websocket connection on 0.0.0.0:7001
2023-10-16T13:44:02.709987Z  WARN sqld: No server heartbeat configured
2023-10-16T13:44:02.710183Z  WARN sqld::config: No authentication specified, the server will not require authentication
2023-10-16T13:44:03.248358Z  INFO sqld::replication::primary::logger: SQLite autocheckpoint: 1000
2023-10-16T13:44:03.250278Z  INFO sqld::namespace: loaded namespace: `default`
2023-10-16T13:44:17.345807Z ERROR sqld::hrana::http: hrana server: Timed out while openning database connection
2023-10-16T13:44:17.345844Z ERROR sqld::error: HTTP API: 500 Internal Server Error, {"error":"Internal Error: `Timed out while openning database connection`"}
2023-10-16T13:44:17.345871Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=1000 ms

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants