go-libsql: failed to execute query - Hrana STREAM_EXPIRED
Hey Guys,
I am getting the following error after ~10s of the connection to the DB being alive:
failed to execute query
...
error code = 1: Error executing statement: Hrana: `api error: `{\"message\":\"The stream has expired due to inactivity\",\"code\":\"STREAM_EXPIRED\"}
Makes this client more or less unusable (don’t want to create a new connection on each request…). Would also be nice to see relative paths working with the client for the embedded replicas.
Thanks!
Repo to reproduce: https://github.com/juliuslipp/libsql-weirdness
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (15 by maintainers)
@haaawk, this is still an issue and not fixed in the CGO version, but works and is not an issue for the non-CGO version. Is this intentional?
We just restarted development on a product that was supposed to use turso on the server side, and we just hit this issue on day 2 of development. I double checked against the examples to see if the original devs missed something, but their code aligns with the go example client code.
The issue is still present in this library (
github.com/tursodatabase/go-libsql), but is not present in thegithub.com/tursodatabase/libsql-client-go/libsqllibrary. This means that if we have a “embedded replica” connection for one of our libsql connections, we cannot use the same library to fallback to “remote-only”, or reuse the connection code for a “remote-only” connection to another db.We’ve tested it both with
turso devanddocker libsqland we get the sameHrana: api error: STREAM_EXPIREDerror.Let me know if you need a github to reproduce this.
Just had the same problem - the DB was empty after restarting. Let me try to replicate this…
If you care about sqlx then you can do:
There are two options:
DB.SetMaxIdleConns(1)DB.SetConnMaxIdleTime(9s)So the NewEmbeddedClient would look like:
You are right. Last time I tried the auto-sync, it didn’t work. That was a few versions ago though.
Ok let me try it.
You’re opening embedded replicas incorrectly. Instead of doing:
the correct way is to do:
What you did was opening embedded replica file with a local only client and that makes it impossible for embedded replicas to work correctly.
Just a comment about syncing embedded replicas: If you do
NewEmbeddedReplicaConnectorWithAutoSyncinstead ofNewEmbeddedReplicaConnectorthen the sync will be done periodically automatically and you don’t need all the: