tursodatabase / tursodatabase/libsql

Crash: thread panicked at value.rs on Utf8Error

Open
#1,223 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

Hi, when running a basic SELECT statement against my database in a nodejs environment the request takes several seconds of processing before it crashes with the following error:

thread '<unnamed>' panicked at /Users/administrator/.cargo/git/checkouts/libsql-00c15cfa15b9f13b/2bdfe31/libsql/src/value.rs:213:40:
called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 3, error_len: Some(1) }
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 134 (interrupted by signal 6:SIGABRT)

Running the same query with other libraries returns data within a few milliseconds.
Also running pragma integrity_check on the database returns ok.

The code is

import { createClient } from "@libsql/client";
export const client = createClient({
    url: import.meta.env.TURSO_DB_URL,
    authToken: import.meta.env.TURSO_DB_AUTH_TOKEN
});
export async function getData(language: string) {
    const statement = "SELECT DISTINCT TABLE.FIELD FROM TABLE; 
    return await client.execute({
        sql:statement, args:[]
  })
}

The database itself is several gigabytes, the issue occurs only in some tables in the database it seems, but I could not see a pattern yet. I also recreated the database from scratch, it did not help.

Setting the environment variable did not seem to create any additional debug logs in the console or log files.

What could be the issue here? How can it be further analysed?

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at libsql/src/value.rs:213 and reproduce the crash with the reported SELECT DISTINCT query against an affected table. Run with RUST_BACKTRACE=full and compare the failing table or value with tables that work. Done means identifying the invalid UTF-8 case and establishing a way for the query to complete or report the problem without panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.