此时的疑问:是哪个过程导致mysqldump执行了,FLUSH /*!40101 LOCAL */ TABLES; 和 FLUSH TABLES WITH READ LOCK;命令?
原因
关于参数,查阅了官方的参数说明,找到了答案
-E, --events Dump events.
-R, --routines Dump stored routines (functions and procedures).
--set-gtid-purged[=name] Add 'SET @@GLOBAL.GTID_PURGED' to the output. Possible
values for this option are ON, OFF and AUTO. If ON is
used and GTIDs are not enabled on the server, an error is
generated. If OFF is used, this option does nothing. If
AUTO is used and GTIDs are enabled on the server, 'SET
@@GLOBAL.GTID_PURGED' is added to the output. If GTIDs
are disabled, AUTO does nothing. If no value is supplied
then the default (AUTO) value will be considered.
--master-data[=#] This causes the binary log position and filename to be appended to the output. If equal to 1, will print it as a
CHANGE MASTER command;if equal to 2, that command will
be prefixed with a comment symbol. This option will turn
--lock-all-tables on, unless --single-transaction is
specified too (in which case a global read lock is only
taken a short time at the beginning of the dump; don't
forget to read about --single-transaction below). In all
cases, any action on logs will happen at the exact moment
of the dump. Option automatically turns --lock-tables
off.
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
参数中说**–master-data**全局锁的时间会很短in which case a global read lock is only taken a short time at the beginning of the dump,但是根据开篇的慢日志记录可以看到,上锁的时间长达120秒。所以影响业务的情况应该包括:上锁时间+锁表时间。