Description:
Lost gtids after crash recovery
How to repeat:
1.Add debug crash point before init_gtid_sets, and rebuild with -DWITH_DEBUG=1
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index cb6f9c5..3c2f201 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4829,6 +4829,8 @@ int mysqld_main(int argc, char **argv)
Gtid_set gtids_in_binlog(global_sid_map, global_sid_lock);
Gtid_set gtids_in_binlog_not_in_table(global_sid_map, global_sid_lock);
+ DBUG_EXECUTE_IF("crash_before_write_prev_gtids", DBUG_SUICIDE(););
+
if (mysql_bin_log.init_gtid_sets(>ids_in_binlog,
&purged_gtids_from_binlog,
opt_master_verify_checksum
2. create mysql-server\mysql-test\suite\binlog\t\lost_gtid.test
```
--source include/have_log_bin.inc
--source include/have_debug.inc
--source include/have_gtid.inc
--source include/gtid_utils.inc
let $DDIR= `select @@datadir`;
CREATE TABLE t1(c1 int, c2 int);
insert into t1 values(1, 1);
insert into t1 values(1, 1);
flush logs;
insert into t1 values(1, 1);
insert into t1 values(1, 1);
select GTID_COUNT(@@GLOBAL.GTID_EXECUTED);
select GTID_COUNT(@@GLOBAL.GTID_PURGED);
select interval_start, interval_end from mysql.gtid_executed;
--echo [kill mysqld not update mysql.executed]
--source include/kill_mysqld.inc
--echo [restart mysqld and crash before write prev_gtids to newest binlog]
#-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
#--let $restart_parameters = restart: --debug=d,crash_before_write_prev_gtids
#--source include/start_mysqld.inc
#--remove_file $MYSQLD_LOG
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 1,137
--exec $MYSQLD_CMD --debug=d,crash_before_write_prev_gtids --gtid_mode=on --enforce_gtid_consistency=on --datadir=$DDIR >$MYSQLTEST_VARDIR/log/mysqld_out_err.log 2>&1
--source include/wait_until_disconnected.inc
--let $restart_parameters = restart:
--source include/start_mysqld.inc
select GTID_COUNT(@@GLOBAL.GTID_EXECUTED);
select GTID_COUNT(@@GLOBAL.GTID_PURGED);
select interval_start, interval_end from mysql.gtid_executed;
#cleanup
drop table t1;
--source include/gtid_utils_end.inc
```
3. run mtr test
./mtr --mem binlog.gtid_lost --mysqld=--gtid_mode=on --mysqld=--enforce_gtid_consistency
Description: Lost gtids after crash recovery How to repeat: 1.Add debug crash point before init_gtid_sets, and rebuild with -DWITH_DEBUG=1 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index cb6f9c5..3c2f201 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4829,6 +4829,8 @@ int mysqld_main(int argc, char **argv) Gtid_set gtids_in_binlog(global_sid_map, global_sid_lock); Gtid_set gtids_in_binlog_not_in_table(global_sid_map, global_sid_lock); + DBUG_EXECUTE_IF("crash_before_write_prev_gtids", DBUG_SUICIDE();); + if (mysql_bin_log.init_gtid_sets(>ids_in_binlog, &purged_gtids_from_binlog, opt_master_verify_checksum 2. create mysql-server\mysql-test\suite\binlog\t\lost_gtid.test ``` --source include/have_log_bin.inc --source include/have_debug.inc --source include/have_gtid.inc --source include/gtid_utils.inc let $DDIR= `select @@datadir`; CREATE TABLE t1(c1 int, c2 int); insert into t1 values(1, 1); insert into t1 values(1, 1); flush logs; insert into t1 values(1, 1); insert into t1 values(1, 1); select GTID_COUNT(@@GLOBAL.GTID_EXECUTED); select GTID_COUNT(@@GLOBAL.GTID_PURGED); select interval_start, interval_end from mysql.gtid_executed; --echo [kill mysqld not update mysql.executed] --source include/kill_mysqld.inc --echo [restart mysqld and crash before write prev_gtids to newest binlog] #-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect #--let $restart_parameters = restart: --debug=d,crash_before_write_prev_gtids #--source include/start_mysqld.inc #--remove_file $MYSQLD_LOG --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 1,137 --exec $MYSQLD_CMD --debug=d,crash_before_write_prev_gtids --gtid_mode=on --enforce_gtid_consistency=on --datadir=$DDIR >$MYSQLTEST_VARDIR/log/mysqld_out_err.log 2>&1 --source include/wait_until_disconnected.inc --let $restart_parameters = restart: --source include/start_mysqld.inc select GTID_COUNT(@@GLOBAL.GTID_EXECUTED); select GTID_COUNT(@@GLOBAL.GTID_PURGED); select interval_start, interval_end from mysql.gtid_executed; #cleanup drop table t1; --source include/gtid_utils_end.inc ``` 3. run mtr test ./mtr --mem binlog.gtid_lost --mysqld=--gtid_mode=on --mysqld=--enforce_gtid_consistency