Bug #86808 Example of mysqldump --single-transaction is wrong (don't issue FTWRL)
Submitted: 23 Jun 2017 8:14 Modified: 23 Jun 2017 19:11
Reporter: Meiji Kimura Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.5, 5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[23 Jun 2017 8:14] Meiji Kimura
Description:
In MySQL 5.5/5.6/5.7 manual said this example issue FTWRL(Flush Table With Read Lock).

shell> mysqldump --single-transaction --all-databases > backup_sunday_1_PM.sql

Manual:
https://dev.mysql.com/doc/refman/5.5/en/backup-policy.html
https://dev.mysql.com/doc/refman/5.6/en/backup-policy.html
https://dev.mysql.com/doc/refman/5.7/en/backup-policy.html

But these options don't issue FTWRL. The source code are here.

~/client/mysqldump.c

5811   if ((opt_lock_all_tables || opt_master_data ||
5812        (opt_single_transaction && flush_logs)) &&
5813       do_flush_tables_read_lock(mysql))
5814     goto err; 

FTWRL is only issue with --master-data, or --flush-logs with --single-transaction.

How to repeat:
Set general_log=on, and issue the example. There is no FTWRL
.
2017-06-22T08:14:05.953699Z	   15 Connect	root@localhost on  using TCP/IP
2017-06-22T08:14:05.954699Z	   15 Query	/*!40100 SET @@SQL_MODE='' */
2017-06-22T08:14:05.954699Z	   15 Query	/*!40103 SET TIME_ZONE='+00:00' */
2017-06-22T08:14:05.958699Z	   15 Query	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
2017-06-22T08:14:05.959699Z	   15 Query	START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
2017-06-22T08:14:05.959699Z	   15 Query	SHOW VARIABLES LIKE 'gtid\_mode'
2017-06-22T08:14:05.964699Z	   15 Query	UNLOCK TABLES

Suggested fix:
Modify Exampl like this.

shell> mysqldump --single-transaction --all-databases --master-data > backup_sunday_1_PM.sql

or 

shell> mysqldump --single-transaction --all-databases --flush-logs > backup_sunday_1_PM.sql
[23 Jun 2017 8:22] MySQL Verification Team
Hello Meiji-San,

Thank you for the report and feedback!

regards,
Umesh
[23 Jun 2017 19:11] Paul DuBois
Posted by developer:
 
Example updated. Thanks!