Skip to content

Commit 85c6116

Browse files
committed
MDEV-34902: debian-start erroneously reports issues
Remove the complexity of check_for_crashed_tables by removing it all together. When check_for_crashed_tables was written there was a desire to recover MyISAM tables. With Aria being default from 10.4 for system tables, and all non-MyISAM engines being able to do crash recovery there isn't the need to autocheck as part of a system service. With check_for_crashed_tables removed there is no need for a mailx package recommendation. Adjusted the bash scripts to use arrays for correct command execution. Corrected message for insecure passwords to refer to the mysql.global_privs table.
1 parent f1aaa75 commit 85c6116

File tree

3 files changed

+6
-71
lines changed

3 files changed

+6
-71
lines changed

debian/additions/debian-start

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,13 @@ then
2222
. /etc/default/mariadb
2323
fi
2424

25-
MARIADB="/usr/bin/mariadb --defaults-extra-file=/etc/mysql/debian.cnf"
26-
MYADMIN="/usr/bin/mariadb-admin --defaults-extra-file=/etc/mysql/debian.cnf"
25+
MARIADB=(/usr/bin/mariadb --defaults-extra-file=/etc/mysql/debian.cnf)
2726
# Don't run full mariadb-upgrade on every server restart, use --version-check to do it only once
28-
MYUPGRADE="/usr/bin/mariadb-upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check --silent"
29-
MYCHECK_SUBJECT="WARNING: mariadb-check has found corrupt tables"
30-
MYCHECK_RCPT="${MYCHECK_RCPT:-root}"
31-
32-
## Checking for corrupt, not cleanly closed (only for MyISAM and Aria engines) and upgrade needing tables.
27+
MYUPGRADE=(/usr/bin/mariadb-upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check --silent)
3328

3429
# The following commands should be run when the server is up but in background
3530
# where they do not block the server start and in one shell instance so that
3631
# they run sequentially. They are supposed not to echo anything to stdout.
37-
# If you want to disable the check for crashed tables comment
38-
# "check_for_crashed_tables" out.
3932
# (There may be no output to stdout inside the background process!)
4033

4134
# Need to ignore SIGHUP, as otherwise a SIGHUP can sometimes abort the upgrade
@@ -44,7 +37,6 @@ trap "" SIGHUP
4437
(
4538
upgrade_system_tables_if_necessary;
4639
check_root_accounts;
47-
check_for_crashed_tables;
4840
) >&2 &
4941

5042
exit 0

debian/additions/debian-start.inc.sh

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,6 @@
33
# This file is included by /etc/mysql/debian-start
44
#
55

6-
## Is there MyISAM or Aria unclosed tables.
7-
# - Requires the server to be up.
8-
# - Is supposed to run silently in background.
9-
function check_for_crashed_tables() {
10-
set -e
11-
set -u
12-
13-
# But do it in the background to not stall the boot process.
14-
logger -p daemon.info -i -t"$0" "Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables"
15-
16-
# Checking for $? is unreliable so the size of the output is checked.
17-
# Some table handlers like HEAP do not support CHECK TABLE.
18-
tempfile=$(mktemp)
19-
20-
# We have to use xargs in this case, because a for loop barfs on the
21-
# spaces in the thing to be looped over.
22-
23-
# If a crashed table is encountered, the "mariadb" command will return with a status different from 0
24-
#
25-
# The first query will generate lines like.
26-
# select count(*) into @discard from 'mysql'.'db'
27-
# The second line will load all tables without printing any actual results,
28-
# but may show warnings and definitely is expected to have some error and
29-
# exit code if crashed tables are encountered.
30-
#
31-
# Note that inside single quotes must be quoted with '\'' (to be outside of single quotes).
32-
set +e
33-
# The $MARIADB is intentionally used to expand into a command and arguments
34-
# shellcheck disable=SC2086
35-
echo '
36-
SELECT CONCAT("select count(*) into @discard from '\''", TABLE_SCHEMA, "'\''.'\''", TABLE_NAME, "'\''")
37-
FROM information_schema.TABLES WHERE TABLE_SCHEMA<>"INFORMATION_SCHEMA" AND TABLE_SCHEMA<>"PERFORMANCE_SCHEMA"
38-
AND (ENGINE="MyISAM" OR ENGINE="Aria")
39-
' | \
40-
LC_ALL=C $MARIADB --skip-column-names --batch | \
41-
xargs --no-run-if-empty -i $MARIADB --skip-column-names --silent --batch --force -e "{}" &> "${tempfile}"
42-
set -e
43-
44-
if [ -s "$tempfile" ]
45-
then
46-
(
47-
/bin/echo -e "\n" \
48-
"Improperly closed tables are also reported if clients are accessing\n" \
49-
"the tables *now*. A list of current connections is below.\n";
50-
$MYADMIN processlist status
51-
) >> "${tempfile}"
52-
# Check for presence as a dependency on mailx would require an MTA.
53-
if [ -x /usr/bin/mailx ]
54-
then
55-
mailx -e -s"$MYCHECK_SUBJECT" "$MYCHECK_RCPT" < "$tempfile"
56-
fi
57-
(echo "$MYCHECK_SUBJECT"; cat "${tempfile}") | logger -p daemon.warn -i -t"$0"
58-
fi
59-
rm "${tempfile}"
60-
}
61-
626
## Check for tables needing an upgrade.
637
# - Requires the server to be up.
648
# - Is supposed to run silently in background.
@@ -70,7 +14,7 @@ function upgrade_system_tables_if_necessary() {
7014

7115
# Filter all "duplicate column", "duplicate key" and "unknown column"
7216
# errors as the script is designed to be idempotent.
73-
LC_ALL=C $MYUPGRADE \
17+
LC_ALL=C "${MYUPGRADE[@]}" \
7418
2>&1 \
7519
| grep -E -v '^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))' \
7620
| logger -p daemon.warn -i -t"$0"
@@ -90,9 +34,9 @@ function check_root_accounts() {
9034
JSON_VALUE(priv, '$.plugin') in ('mysql_native_password', 'mysql_old_password', 'parsec') AND
9135
JSON_VALUE(priv, '$.authentication_string') = '' AND
9236
JSON_VALUE(priv, '$.password_last_changed') != 0
93-
" | $MARIADB --skip-column-names)
37+
" | "${MARIADB[@]}" --skip-column-names)
9438
if [ "$ret" -ne "0" ]
9539
then
96-
logger -p daemon.warn -i -t"$0" "WARNING: mysql.user contains $ret root accounts without password!"
40+
logger -p daemon.warn -i -t"$0" "WARNING: mysql.global_priv contains $ret root accounts without password!"
9741
fi
9842
}

debian/control

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ Description: MariaDB database core server files
674674

675675
Package: mariadb-server
676676
Architecture: any
677-
Suggests: mailx,
678-
mariadb-test,
677+
Suggests: mariadb-test,
679678
netcat-openbsd
680679
Recommends: libhtml-template-perl,
681680
pv

0 commit comments

Comments
 (0)