[MDEV-25434] mariadb container to have HEALTHCHECK Created: 2021-04-17 Updated: 2022-03-31 Resolved: 2022-02-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Docker |
| Fix Version/s: | 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2, 10.8.1 |
| Type: | Task | Priority: | Major |
| Reporter: | Daniel Black | Assignee: | Daniel Black |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
|
| Comments |
| Comment by Alexey Bychko (Inactive) [ 2021-04-28 ] | ||||||||||||||||||||||||
|
what is the preferred health check? I can run something like SELECT VERSION(), but we can implement something smart here I think | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-04-28 ] | ||||||||||||||||||||||||
|
the docs mentions something like the output is recorded. So innodb recovery and/galera status would be useful here. I'm not sure either of those will push it into unhealthy, but maybe its output would be useful. | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-04-28 ] | ||||||||||||||||||||||||
|
Also the purpose is to ensure that the container it has started, so careful not to return 'healthy' on the db initialization entrypoint stages. | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-05-12 ] | ||||||||||||||||||||||||
|
Also think how this would integrate with a mysql_upgrade in a container (https://github.com/MariaDB/mariadb-docker/issues/350) such that a healthy is returning after upgrade or fresh install. | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-05-12 ] | ||||||||||||||||||||||||
|
https://github.com/docker-library/healthcheck/blob/master/mysql/docker-healthcheck maybe a good starting point. readworthy - https://github.com/MariaDB/mariadb-docker/issues/94 | ||||||||||||||||||||||||
| Comment by Alexey Bychko (Inactive) [ 2021-05-12 ] | ||||||||||||||||||||||||
|
a comment from github:
| ||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-05-19 ] | ||||||||||||||||||||||||
|
So there's no way we can do a release with a HEALTHCHECK directive however including the script in the container without a HEALTHCHECK enable should still be valuable (and better than what the user can write themselves) and consistent with current accepted official images. Github comment generally corresponds to https://github.com/docker-library/faq#healthcheck and answering the points:
Fair call, lets provide a healthcheck script that can provide a basic port exposed check (as readiness) which should provide the base of a user check should they choose to use it.
With the basic readiness as a port based check it probably won't need credentials. But if you go for a full connection, see extra-port and dedicated user below. If a user enables HEALTHCHECK or docker/podman run --health-cmd= then they can be responsible for ensuring those are still there (or the consequence of the script failing and erroring).
I don't expect this would be too much load, but without a HEALTHCHECK directive this won't be used.
To account for the kubernetes case, lets make the script accept --liveness option (default to just "readiness") that provides that additional checking those according to the kubernetes documentation - https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ . Given the liveness (and maybe readiness) test would require a db connection we probably should include the extra-port/extra_max_connections in the default config (https://github.com/MariaDB/mariadb-docker/blob/master/Dockerfile.template#L116) and use that for the connection so we don't fail liveness when we run out of max-connections. Adding an extra user to the entrypoint with a minimum amount of privs would hopefully be immune to the the authentication changes that usually go on, but simply error out if this user doesn't exist is reasonable grounds to just error on the liveliness check. Looking forward to seeing what you come up with in terms of a liveness test. I'd be happy for the script to accept a variety of options if you consider various liveness tests that you may not want to be always there. Please update documentation on how to use this: https://github.com/docker-library/docs/tree/master/mariadb | ||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-06-23 ] | ||||||||||||||||||||||||
|
A fairly obvious generic minimal healthcheck for a MariaDB server could be mysqladmin status call.
It does require an existing user account, but it's unprivileged account, just USAGE is enough, which makes it an easier option than some other status-related queries. | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2022-02-01 ] | ||||||||||||||||||||||||
|
created https://github.com/MariaDB/mariadb-docker/pull/408, in review with faust | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2022-02-03 ] | ||||||||||||||||||||||||
|
Found some odd behaviour with mysqladmin in MDEV-27731 and because I hadn't implemented a --user arg, it would have hit users quickly. Might add it later. mysqladmin ping also there an less output.
| ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-03-30 ] | ||||||||||||||||||||||||
|
When it comes to InnoDB, I think that it might make sense to implement a systemd watchdog (MDEV-24669), a dead man’s switch that would be actuated every now and then, and would be blocked if dict_sys.mutex or dict_sys.latch cannot be acquired for a long time. The InnoDB health might also be computed from some performance metrics, but I do not have specific ideas. The checkpoint age (log bytes written since the latest checkpoint) or the number of dirty pages in the buffer pool may not be reasonable measures if idle page flushing ( Perhaps there could be a ‘health formula’ that could be re(de)fined by the DBA to match the deployment? Something like a user-defined function that would return a single number? | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2022-03-31 ] | ||||||||||||||||||||||||
|
Noted. There's some talk of partial integration of systemd features into container runtimes, but its still fairly conceptual only at the moment. I was considering a generic query as an argument to the script to leave it to any function the DBA wants. User's aren't currently tied to using the healthcheck script provided. |