-
Notifications
You must be signed in to change notification settings - Fork 2
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
shows "status: up" with missing sqlite database #20
Comments
@tacman I do not undertstand this correctly I think. You state SQLite and Postgress. Can you share the exact error from the log? And the exact steps to reproduce? |
Here's a simple demo that uses sqlite. When you delete the database the home page returns a 500, but the monitor shows it's okay. git clone [email protected]:survos-sites/barcode-demo.git && cd barcode-demo
composer install
symfony server:start -d
symfony open:local
symfony open:local --path="/internal/health"
read -p "press any key to delete the database" -n 1 -s
rm products.db
symfony open:local
symfony open:local --path="/internal/health" |
https://github.com/survos-sites/barcode-demo/blob/main/config/packages/doctrine.yaml#L41 |
That's only in prod. The issue is, of course, that the website is down if you delete the database and open the site. I guess that's what I'm expecting the monitor to catch. If the home page is broken but the /health status says "up", I must be mis-configuring something. |
@tacman Thanks for the repo, it helps me investigating the problem(s) I am currently investigating it... seeing that for SQLite, the behaviour is that the database is created (empty) if it is not there. Theherfor, the check that it exists and a connection can be made will succeed. Then we check if it has tables, and only then, it will execute the test query. If not, nothing happens at the moment. Maybe we should throw an exception if the tables are empty as well. @thijskh do we want to support SQLite as well? |
@tacman can you test this PR? In the manuals, the default behaviour of the Sqlite3 driver, is to create the database(file) if it does not exists |
Hmm. So if the database exists, it passes. Then there are no tables (which is legit), so it passes. Gut feeling is that the better solution is to allow the user to define one or more queries that can optionally be run, as discussed before. Or drop SQLite? I use SQLite for testing so I don't have to spin up a database, but on the production site, where I use Postgres, the monitor works as expected. |
Ugh, I forget how to test a PR on a 3rd-party library! |
@tacman sometimes I clone the project with the vender code I want to test. And then create a symlink to that clone in my vendor folder. Alternatively you can add a 'repositories' section in your composer.json. And install the monitor bundle dependency from a branch you specify there.
|
We'd definitely be open to a PR that would provide the SQL query as a configurable string. |
I updated the bundle, when to /internal/health, all good.
I then deleted my sqlite database, and it still said it was good.
However, a bad postgres connection does correctly show status: down.
The text was updated successfully, but these errors were encountered: