-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Recap unable to log the InnoDB engine status in MySQL 8.0 or later.
The Problem is that below piece of code in bash script file "/usr/lib/recap/core/mysql" not able to fetch the InnoDB engine status.
for name in "/proc/"$(cat ${PID_FILE})"/fd/"*; do
# We know that InnoDB's temporary files are always in the mysql tmpdir
# and start with the string 'ib' followed by a randomly generated series
# of characters. Now we can compare the canonicalized path of fd to the
# tmpdir/ib* pattern:
**if [[ "$(readlink -f "${name}")" == "${TMPDIR}"/ib* ]]; then**
# If any files match that pattern, we see if the first line in the file
# starts with "===", which is the case in the particular InnoDB file we
# care about:
head -c8 "${name}" | grep -q '^====' && cat "${name}" >> "${LOGFILE}"
fi
done
-
The line "if [[ "$(readlink -f "${name}")" == "${TMPDIR}"/ib* ]]" specifically looks for a innodb's temporary file in the mysql tmpdir that starts with string 'ib'. This file typically contains the InnoDB engine status after recaptool executes the "SHOW ENGINE InnoDB STATUS" command during its runtime.
-
MariaDB and MySQL (likely earlier versions) generates these files with a prefix of 'ib, but with MySQL 8 or later, it appears such files no longer begin with 'ib'. As a result, the bash script "/usr/lib/recap/core/mysql" fails to match the condition and is unable to log the InnoDB engine status in the recap log.
-
I removed 'ib' in the 'if' condition on my test server and it started logging innodb engine status now.
File Changed: "/usr/lib/recap/core/mysql"
From:
if [[ "$(readlink -f "${name}")" == "${TMPDIR}"/ib* ]];
To:
if [[ "$(readlink -f "${name}")" == "${TMPDIR}"/* ]];
On Test Server:
[root@saur7971test recap]# mysql -V
mysql Ver 8.0.41 for Linux on x86_64 (Source distribution)
[root@saur7971test recap]# ps -efa | grep -i sql
mysql 864 1 0 08:44 ? 00:00:29 /usr/libexec/mysqld --basedir=/usr
root 57120 52977 0 10:39 pts/0 00:00:00 grep --color=auto -i sql
[root@saur7971test recap]# ls -l /proc/864/fd/6
lrwx------. 1 root root 64 Jul 23 08:48 /proc/864/fd/6 -> '/var/tmp/#408831 (deleted)' <<<< no 'ib' in file name under /var/tmp
[root@saur7971test recap]# head /proc/864/fd/6
=====================================
2025-07-23 10:30:19 140207199307328 INNODB MONITOR OUTPUT
Per second averages calculated from the last 1 seconds
BACKGROUND THREAD
srv_master_thread loops: 1 srv_active, 0 srv_shutdown, 6329 srv_idle
srv_master_thread log flush and writes: 0
[root@saur7971test recap]# grep -iA1 innodb mysql_20250723-103009.log
MySQL (/root/.my.cnf) InnoDB status
--
2025-07-23 10:30:19 140207199307328 INNODB MONITOR OUTPUT
--
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=864, Main thread ID=140206783063616 , state=sleeping
END OF INNODB MONITOR OUTPUT
Teams Chat Reference: https://teams.microsoft.com/l/message/19:[email protected]/1753267316468?context=%7B%22contextType%22%3A%22chat%22%7D