33# This file is included by /etc/mysql/debian-start
44#
55
6+ # # Is there MyISAM or Aria system tables needing fixing
7+ # We want to recover these quickly before an upgrade.
8+ function check_for_crashed_system_tables()
9+ {
10+ set -e
11+ set -u
12+
13+ logger -p daemon.info -i -t" $0 " " Triggering fast check and recovery for system tables"
14+ " ${MARIADBCHECK[@]} " mysql
15+ }
16+
617# # Is there MyISAM or Aria unclosed tables.
718# - Requires the server to be up.
819# - Is supposed to run silently in background.
920function check_for_crashed_tables() {
1021 set -e
1122 set -u
1223
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} "
24+ logger -p daemon.info -i -t" $0 " " Triggering fast check and recovery for all tables"
25+ " ${MARIADBCHECK_ALL[@]} "
6026}
6127
6228# # Check for tables needing an upgrade.
@@ -70,7 +36,7 @@ function upgrade_system_tables_if_necessary() {
7036
7137 # Filter all "duplicate column", "duplicate key" and "unknown column"
7238 # errors as the script is designed to be idempotent.
73- LC_ALL=C $ MYUPGRADE \
39+ LC_ALL=C " ${ MYUPGRADE[@]} " \
7440 2>&1 \
7541 | grep -E -v ' ^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))' \
7642 | logger -p daemon.warn -i -t" $0 "
@@ -90,9 +56,9 @@ function check_root_accounts() {
9056 JSON_VALUE(priv, '$.plugin') in ('mysql_native_password', 'mysql_old_password', 'parsec') AND
9157 JSON_VALUE(priv, '$.authentication_string') = '' AND
9258 JSON_VALUE(priv, '$.password_last_changed') != 0
93- " | $ MARIADB --skip-column-names)
59+ " | " ${ MARIADB[@]} " --skip-column-names)
9460 if [ " $ret " -ne " 0" ]
9561 then
96- logger -p daemon.warn -i -t" $0 " " WARNING: mysql.user contains $ret root accounts without password!"
62+ logger -p daemon.warn -i -t" $0 " " WARNING: mysql.global_priv contains $ret root accounts without password!"
9763 fi
9864}
0 commit comments