Create file with current MySQL state
Description
Environment
Activity
Julia Vural September 30, 2024 at 8:24 AM
We already have a working solution. However, there is a different (socket approach) already available in the product. That is why we have decided to not check-in the changes.
Kamil Holubicki September 19, 2024 at 12:49 PM
As we discussed on MySql Support Triage Meeting, I’m putting this ticket to ‘On Hold’. Will be deescalated and closed after confirmation that already existing “socket solution” works in production or it will be reopened and we will continue with the file approach.
Kamil Holubicki September 19, 2024 at 12:13 PM
Summarizing what we have said on Slack:
@ege.gunes validated that already existing functionality with socket can be used
There are still some concerns about stability of messages strings sent by PS, but they didn’t change from version 8.0.17, so we don’t expect any changes here.
We will go with the already existing “socket” functionality. If we find later that it is not working well for us, we will reopen this ticket and go with a status file.
As already mentioned, “status file” functionality has been implemented here.
To obtain the server state, the consumer will have to do something like this:
#!/bin/bash MYSQL_DATADIR=/home/kamil/repo/pxc/8.0/install/pxc-node/dn1 SERVER_STATE_FILE=${MYSQL_DATADIR}/server.state SERVER_STATE=$(flock -s ${SERVER_STATE_FILE} cat ${SERVER_STATE_FILE}) echo ${SERVER_STATE}
file locking on the consumer side can be skipped, but that doesn’t guarantee consistent result (read may be done in the middle of the write)
lock time on the consumer side has to be short; server continues with write after 5 secs regardless of being able to lock the file exclusively
ege.gunes June 19, 2024 at 1:53 PM
@Kamil Holubicki parsing the log programmatically would be very problematic, since we need to understand where does it start and where does it end and if it’s relevant right now.
Solution doesn’t require to be file, it was just an idea. Basically we want to differentiate between three states:
Database is ready and can accept connections
Database is dead and must be restarted
Limbo state: Database is up but can’t accept connections (for example recovering)
If file is an OK solution it can be in /var/lib/mysql
and it can be plaintext containing strings or integers. But we’re OK with anything that can be check in a bash script.
Aaditya Dubey June 17, 2024 at 8:26 AM
Hi @ege.gunes
Thank you for the report.
Details
Details
Assignee
Reporter
Labels
Planned Version/s
Needs QA
Needs Doc
In progress time
Time tracking
Sprint
Priority
Smart Checklist
Open Smart Checklist
Smart Checklist

In k8s operators, we need to handle different MySQL states correctly like ‘ready/upgrading/crash recovery’. This is especially important for automated health checks which decide if MySQL process should be restarted. For example database can be unavailable during crash recovery but shouldn’t be restarted to let recovery finish.