-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
I'm not sure if this is an intended limitation but if a write transaction takes longer to complete, the connection/stream seems to get terminated abruptly as if there is some timeout.
Here is minimal Go example:
package main
import (
"context"
"database/sql"
"log"
"time"
_ "github.com/tursodatabase/libsql-client-go/libsql"
)
func main() {
url := "..."
db, err := sql.Open("libsql", url)
if err != nil {
log.Fatalf("failed to open db %s: %s", url, err)
}
defer db.Close()
tx, err := db.BeginTx(context.Background(), nil)
if err != nil {
log.Fatalf("BeginTx error: %v", err)
}
defer tx.Rollback()
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS `test` (id VARCHAR(255) PRIMARY KEY NOT NULL)")
if err != nil {
log.Fatalf("before sleep error: %v", err)
}
// simulate large and slow transaction
time.Sleep(10 * time.Second)
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS `test` (id VARCHAR(255) PRIMARY KEY NOT NULL)")
if err != nil {
log.Fatalf("after sleep error: %v", err)
}
err = tx.Commit()
if err != nil {
log.Fatalf("commit error: %v", err)
}
}
The above fails with the following error:
2025/04/20 16:01:21 after sleep error: failed to execute SQL:
error code 404: stream not found: 0fadcb26:01965349-eea6-79f0-8f02-80077f780223
For more context, the issue was original reported in pocketbase/pocketbase#6746.
It is also possible to be related to tursodatabase/libsql#985.
zeshhaan, roughbits01, katriellucas, MouamleH, daibertdiego and 7 more
Metadata
Metadata
Assignees
Labels
No labels