-
-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite tables disappear? #2059
Comments
DSN of memory means „in memory database“ and it is lost once kratos restarts. Please use a file instead for SQLite or mysql or postgres! Thank you - hope this helps. |
@aeneasr Hm... Would Kratos restart on its own? I'm just running it with docker compose in the background. Also, I'm not talking about data disappearing. Kratos API randomly gives me 500 errors, apparently because some sqlite tables don't exist (even though they did before). |
I'm basically writing some tests and running them every now and then. Everything seems to be fine, until at some point I get that 500 error apparently for no reason and have to restart docker compose. It just happened again. It might not happen with Postgres (I haven't checked), but it's still concerning. |
Sorry, I closed on accident. Hard to say really, the SQLite adapter is for testing, don’t use it in production or whenever you need the DB to persist. |
We use SQLite internally for testing and e2e testing also, it’s very stable and we have never observed any issues. The problem you describe sounds like an issue with the setup or something else, not sure. If you have a reproducible case that you can put on github that would be very helpful. Otherwise it’s very very difficult to figure out what’s going on |
I understand that and I'm using it only for testing. It's probably not going to break our CI, since it seems to work after a fresh start, but it fails occasionally when I run tests locally against docker compose that's been running for some time. I'll see if I can figure out the conditions to reproduce this and post more info if I do. |
You can try to use shared mode for SQLite: https://github.com/ory/x/blob/8dca295c04c24fd8e1c8db5b30112358828ea0e7/dbal/dsn.go#L9 |
@kszafran I think I figured out what's going on! The problem appears to be that the Go SQL connection pooling, in some cases, re-establishes a connection. Then, it uses a new SQLite in memory database (as per SQLite docs every connection gets their own DB), which then ends up with an empty table. As a workaround, I have introduced: ory/x#487 Which appears to resolve these flakes. We have not used this in Ory Kratos yet though. Sorry for being so critical in the initial check but I kept it on the radar :) |
I'm glad you were able to trace the problem! I've been using Postgres for testing lately, so this issue hasn't bothered me, but it was somewhat concerning. |
Nice, I think this problem probably most likely occurs when using parallelism as that is the most likely source of go connection pooling creating more connections. Go's connection pooling should actually not establish new connections when using SQLite in memory but yeah... |
Preflight checklist
Describe the bug
Hello! I have a docker-compose file with Kratos and I'm running some tests against it: creating an identity, going through the recovery flow, logging in and finally deleting the identity. In general, it works. But I've already gotten this 500 error twice:
One time I also noticed that the Kratos container just stopped (I was not running mailslurper then and failures to resolve the mailslurper address were the last logged lines. Maybe it had something to do with it?)
This seems to happen when I let the Kratos container sit in the background, while I keep writing and running tests. After I
docker compose down
anddocker compose up -d
, everything is fine again.I imagine this might be something specific to in-memory sqlite?
Reproducing the bug
I can't reproduce it on reliably, but here's my docker-compose.yaml for reference:
Relevant log output
Relevant configuration
Version
v0.8.0-alpha.3
On which operating system are you observing this issue?
macOS
In which environment are you deploying?
Docker Compose
Additional Context
No response
The text was updated successfully, but these errors were encountered: