Bug #95600 Pervious-gtid lost gtid in binlog file
Submitted: 2 Jun 14:59 Modified: 20 Jun 18:09
Reporter: kfpanda kf Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[2 Jun 14:59] kfpanda kf
Description:
Pervious-gtid lost gtid in binlog file.

How to repeat:
Here is an MTR test case.Pervious-gtid from master-bin.000003 lost a gtid.

//bug_pervious_gtid_event_in_binlog-master.opt
--binlog_order_commits=off --gtid_mode=on --enforce_gtid_consistency=true 

//bug_pervious_gtid_event_in_binlog.test

--source include/have_log_bin.inc
--source include/have_gtid.inc
#
# We need the Debug Sync Facility.
#
--source include/have_debug_sync.inc

show variables like 'binlog_order_commits';
--echo ###########################
--echo # prepare                 #
--echo ###########################
show binary logs;
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection default;

# Clean up resources used in this test case.
--disable_warnings
SET DEBUG_SYNC= 'RESET';
--enable_warnings

let $MYSQLD_DATADIR= `select @@datadir`;
create table t(id int);
flush logs;

--echo ###########################
--echo # test                    #
--echo ###########################
--echo #session 1: drop table t
connection con1;
set debug_sync='finish_commit_before_update_executed_gtid WAIT_FOR go';
send
drop table t;

--sleep 1
--echo #session 2: flush logs
connection con2;
flush logs;
set debug_sync='now SIGNAL go';
show binary logs;

connection con1;
--reap
flush logs;
flush logs;
show binary logs;

--echo #######################################################
--echo # binlog:master-bin.000001                            #
--echo #######################################################
--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/master-bin.000001

--echo #######################################################
--echo # binlog:master-bin.000002                            #
--echo #######################################################
--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/master-bin.000002

--echo #######################################################
--echo # binlog:master-bin.000003                            #
--echo #######################################################
--echo # Here's the problem.
--echo # Pervious -gtid from master-bin.000003 lost a gtid.
--echo #
--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/master-bin.000003

--echo #######################################################
--echo # binlog:master-bin.000004                            #
--echo #######################################################
--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/master-bin.000004
disconnect con1;
disconnect con2;
connection default;

# Clean up resources used in this test case.
--disable_warnings
SET DEBUG_SYNC= 'RESET';
--enable_warnings
[3 Jun 1:40] kfpanda kf
Sorry.I forgot to say one thing. 
You need in the function MYSQL_BIN_LOG::finish_commit(THD * THD) Add DEBUG_SYNC(THD, "finish_commit_before_update_executed_gtid") before owned_gtid.is_empty());
[20 Jun 18:09] Bogdan Kecman
Thanks for the test case.

all best
Bogdan