Bug #109937 mysqldump introduces errant gtids on 5.7.41

Submitted: 4 Feb 2023 18:02 Modified: 6 Feb 2023 8:28
Reporter: Leonardo Fernandes Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:5.7.41 OS:Any
Assigned to: CPU Architecture:Any

[4 Feb 2023 18:02] Leonardo Fernandes
Description:
Due to the fix below introduced in 5.7.41, mysqldump now executes a FLUSH TABLES before dumping the data. If mysqldump executes on a replica, it introduces a new GTID_EXECUTED entry, creating an errant GTID.
"The data and the GTIDs backed up by mysqldump were inconsistent when the options --single-transaction and --set-gtid-purged=ON were both used. It was because GTID_EXECUTED was fetched at the end of the dump, at which point the GTIDs on the server could have increased already. With this fixed, a FLUSH TABLES WITH READ LOCK is performed at the beginning of the dump and GTID_EXECUTED was fetched right after, to ensure its value is consistent with the snapshot taken by mysqldump."

How to repeat:
With mysqldump version 5.7.41, create a dump from a replica using GTID, and then run show master status and observe the errant GTID being introduced.

Behavior with mysqldump 5.7.40:
$ /opt/mysql/5.7.40/bin/mysqldump -umsandbox -pmsandbox --socket=/tmp/mysql_sandbox39437.sock --set-gtid-purged=OFF --add-drop-table --single-
transaction --events --routines=true test > test.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

$ ./use -e "show master status\G"
*************************** 1. row ***************************
             File: mysql-bin.000002
         Position: 154
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set: 00039436-1111-1111-1111-111111111111:1-19

Behavior with mysqldump 5.7.41:
$ /opt/mysql/5.7.41/bin/mysqldump -umsandbox -pmsandbox --socket=/tmp/mysql_sandbox39437.sock --set-gtid-purged=OFF --add-drop-table --single-
transaction --events --routines=true test > test.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

$ ./use -e "show master status\G"
*************************** 1. row ***************************
             File: mysql-bin.000002
         Position: 294
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set: 00039436-1111-1111-1111-111111111111:1-19,
00039437-2222-2222-2222-222222222222:1

$ /opt/mysql/5.7.41/bin/mysqldump -umsandbox -pmsandbox --socket=/tmp/mysql_sandbox39437.sock --set-gtid-purged=OFF --add-drop-table --single-
transaction --events --routines=true test > test.sql

Suggested fix:
Set sql_log_bin=0 in mysqdump before running the flush tables to avoid adding any entries to the binary log.
[6 Feb 2023 8:28] MySQL Verification Team
Hello Leonardo,

Thank you for the report and feedback.

Related - Bug #109685, Bug #109701, and internally reported Bug 35020512(not accessible).

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.