Create file with current MySQL state

Description

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.

Environment

None

Activity

Show:

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:

  1. validated that already existing functionality with socket can be used

  2. 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.

  3. 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.

  4. As already mentioned, “status file” functionality has been implemented here.

    1. 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}
    2. 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)

    3. 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

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:

  1. Database is ready and can accept connections

  2. Database is dead and must be restarted

  3. 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

Thank you for the report.

Won't Do

Details

Assignee

Reporter

Labels

Needs QA

Yes

Needs Doc

Yes

In progress time

1

Time tracking

No time logged1d 1m remaining

Sprint

Priority

Smart Checklist

Created June 12, 2024 at 3:12 PM
Updated December 23, 2024 at 11:41 AM
Resolved September 30, 2024 at 8:24 AM

Flag notifications