Skip to content

Commit

Permalink
17037 FIX Adapt change from werk #17035 for MariaDB
Browse files Browse the repository at this point in the history
With the change introduced with werk #17035, if a system was using a MariaDB version higher than 8, it would cause the MySQL DB service to go to unknown.
This was due to the fact that the command 'SHOW REPLICA STATUS' is not available in MariaDB version lower than 10.5.

Change-Id: I4dc1e830c729cced06b77069e5291a13e14e1a3c
  • Loading branch information
racicLuka committed Jan 27, 2025
1 parent c99cd42 commit 49b157d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .werks/17035.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class | feature
edition | cre
component | checks
level | 1
compatible | yes
compatible | no

From MySQL 8.0.22, SHOW SLAVE STATUS is deprecated and the alias SHOW REPLICA STATUS should be used instead.
The statement works in the same way as before, only the terminology used for the statement and its output has changed.

For the sake of compatibility, the service name will stay the same 'MySQL Slave'.
There is no user intervention required.
The user needs to update the agent in order for this to change to work as intended.
15 changes: 15 additions & 0 deletions .werks/17037.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[//]: # (werk v2)
# Adapt change from werk #17035 for MariaDB

key | value
---------- | ---
date | 2024-09-27T22:58:37+00:00
version | 2.4.0b1
class | fix
edition | cre
component | checks
level | 1
compatible | yes

With the change introduced with werk #17035, if a system was using a MariaDB version higher than 8, it would cause the MySQL DB service to go to unknown.
This was due to the fact that the command 'SHOW REPLICA STATUS' is not available in MariaDB version lower than 10.5.
11 changes: 8 additions & 3 deletions agents/plugins/mk_mysql
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ do_query() {
FROM information_schema.TABLES GROUP BY table_schema"

MYSQL_VERSION=$($MYSQL --defaults-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -s -e "SELECT VERSION();" | grep -o '^[0-9]\+')
MYSQL_FULL_VERSION=$($MYSQL --defaults-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -s -e "SELECT VERSION();")

echo "<<<mysql_replica_slave>>>"
echo "$INSTANCE_HEADER"
if [ "$MYSQL_VERSION" -ge 8 ]; then
STATUS_COMMAND="show replica status\G"

if echo "$MYSQL_FULL_VERSION" | grep -q "MariaDB"; then
STATUS_COMMAND="SHOW SLAVE STATUS\G"
elif [ "$MYSQL_VERSION" -ge 8 ]; then
STATUS_COMMAND="SHOW REPLICA STATUS\G"
else
STATUS_COMMAND="show slave status\G"
STATUS_COMMAND="SHOW SLAVE STATUS\G"
fi
$MYSQL --defaults-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -s \
-e "$STATUS_COMMAND"
Expand Down

0 comments on commit 49b157d

Please sign in to comment.