BUG with FIX: Found a syntax bug in the liveness-check

Hi there,

I recently redeployed my Percona XtraDB Cluster with Percona XtraDB Operator using helm on a self-hosted k8s cluster. The database is accessible, but the pxc pods keep restarting, here is the describe pod:

(base) bash: $ kubectl describe pod percona-qa-pxc-0
Events:
  Type     Reason     Age                   From     Message
  ----     ------     ----                  ----     -------
  Warning  Unhealthy  112s (x331 over 10h)  kubelet  Liveness probe failed: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"wsrep_cluster_status"' at line 1
+ [[ -n '' ]]
+ exit 1

Trace this error message down to the Liveness: exec [/var/lib/mysql/liveness-check.sh] which is here

Reproduced using mysql CLI:

(base) bash: $ mysql -h xxxx -uroot -p -e 'SHOW GLOBAL STATUS LIKE "wsrep_cluster_status";'
Enter password: 
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wsrep_cluster_status' at line 1

the fix: Need to resolve the conflict of single quote and double quote

(base) bash: $ mysql -h xxxxx -uroot -p -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_status';"
Enter password: 
+----------------------+---------+
| Variable_name        | Value   |
+----------------------+---------+
| wsrep_cluster_status | Primary |
+----------------------+---------+

Hi @drew_datajoint !
Thanks for info, just a reminder that there is a forum section for operators here so you might want to use it in the future.

Another thing is you can contribute to the operator via pull request or Jira ticket in K8SPXC project.
If you’re not for that we will investigate the issue, but it’s always cool to get user contributions.

Kind regards,
Tomislav

Also one other thing, which kubernetes operator version are you using and which PXC version?

Because with 1.12.0 operator and PXC 8.0.29 this seems to work just fine and there is no difference between the two commands:

bash-4.4$ mysql -h cluster1-pxc-0 -uroot -p -e 'SHOW GLOBAL STATUS LIKE "wsrep_cluster_status";'
Enter password:
+----------------------+---------+
| Variable_name        | Value   |
+----------------------+---------+
| wsrep_cluster_status | Primary |
+----------------------+---------+
bash-4.4$ mysql -h cluster1-pxc-0 -uroot -p -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_status';"
Enter password:
+----------------------+---------+
| Variable_name        | Value   |
+----------------------+---------+
| wsrep_cluster_status | Primary |
+----------------------+---------+

I’m using:

crVersion: 1.12.0

tag: 8.0.29-21.1

and mysql client: mysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)

and I do have the ANSI_QUOTES config in the mysqld:

sql_mode=ALLOW_INVALID_DATES,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,PAD_CHAR_TO_FULL_LENGTH,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,ANSI,TRADITIONAL

The ANSI_QUOTES sql_mode is most likely the culprit here, as that is not default, nor typically used. Good on you for pointing that out. Please create a JIRA with your fix so that our team can include it in the next release!

Hi Matthew,
Thanks! I just verified without the ANSI_QUOTES, it works.

I’ll also re-evaluate my sql_mode configs. I’m happy to contribute but I’ve never used Jira before, is it possible for me to make a PR from my fork? Or can you guide me to a tutorial of how to contribute on Percona’s Jira if it’s easier for you?

Yep, you can create a PR to our repo from your fork. Everything is public on our github. For the JIRA, just hit https://jira.percona.com, create an account (free), and then Create a new issue on the operators project. Put in some details with your patch file and submit. That’s it.

Thanks! I just opened a PR