PS-9132 mysql.gtid_executed persistent GTID info lost when MySQL cras… #5293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…h in Gtid_state::save
mysql.gtid_executed is used to preserve the assigned GTIDs of all the transactions applied on a MySQL server. mysql> reset master;
Query OK, 0 rows affected (0.01 sec)
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 313 |
+------------------+-----------+
1 row in set (0.00 sec)
mysql> select * from mysql.gtid_executed;
Empty set (0.00 sec)
above is normal.
simulation environment MySQL is crashed because of OOM or killed, kill -9 (pid of MySQL)
gdb 'mysqld'
b Gtid_state::save
run --defaults-file=/etc/my.cnf
when gdb goto the breakpoint Gtid_state::save
Breakpoint 1, Gtid_state::save (this=0x3045710, gtid_set=0x7fffffffdfb0) at/percona-server-5.7.44-48/sql/rpl_gtid_state.cc:752 752 DBUG_ENTER("Gtid_state::save(Gtid_set *gtid_set)");
kill -9 (pid of MySQL)again
now start the MySQL
mysql> select * from mysql.gtid_executed;
Empty set (0.00 sec)
mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 313 |
| mysql-bin.000002 | 123 |
| mysql-bin.000003 | 398 |
+------------------+-----------+
3 rows in set (0.00 sec)
mysql> show binlog events in 'mysql-bin.000001';
+------------------+-----+----------------+-----------+-------------+-------------------------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +------------------+-----+----------------+-----------+-------------+-------------------------------------------------------------------+ | mysql-bin.000001 | 4 | Format_desc | 111 | 123 | Server ver: 5.7.44-48-debug-log, Binlog ver: 4 | | mysql-bin.000001 | 123 | Previous_gtids | 111 | 154 | | | mysql-bin.000001 | 154 | Gtid | 111 | 219 | SET @@SESSION.GTID_NEXT= '190ed983-db8b-11ee-b975-0242ab50d9bf:1' | | mysql-bin.000001 | 219 | Query | 111 | 313 | create database test | +------------------+-----+----------------+-----------+-------------+-------------------------------------------------------------------+ 4 rows in set (0.01 sec)
after MySQL restart the gitd in mysql-bin.000001mysql.gtid_executed is lost. the SQL "create database test" gitd in mysql-bin.000001mysql.gtid_executed is lost.
after apply this PR
mysql> select * from mysql.gtid_executed;
+--------------------------------------+----------------+--------------+ | source_uuid | interval_start | interval_end |
+--------------------------------------+----------------+--------------+ | 190ed983-db8b-11ee-b975-0242ab50d9bf | 1 | 1 |
+--------------------------------------+----------------+--------------+
mysql> select * from mysql.gtid_executed;
+--------------------------------------+----------------+--------------+ | source_uuid | interval_start | interval_end |
+--------------------------------------+----------------+--------------+ | 190ed983-db8b-11ee-b975-0242ab50d9bf | 1 | 1 |
+--------------------------------------+----------------+--------------+ 1 row in set (0.00 sec)
mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 313 |
| mysql-bin.000002 | 123 |
| mysql-bin.000003 | 438 |
+------------------+-----------+
mysql> show binlog events in 'mysql-bin.000001';
+------------------+-----+----------------+-----------+-------------+-------------------------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +------------------+-----+----------------+-----------+-------------+-------------------------------------------------------------------+ | mysql-bin.000001 | 4 | Format_desc | 111 | 123 | Server ver: 5.7.44-48-debug-log, Binlog ver: 4 | | mysql-bin.000001 | 123 | Previous_gtids | 111 | 154 | | | mysql-bin.000001 | 154 | Gtid | 111 | 219 | SET @@SESSION.GTID_NEXT= '190ed983-db8b-11ee-b975-0242ab50d9bf:1' | | mysql-bin.000001 | 219 | Query | 111 | 313 | create database test |
the gtid in mysql-bin.000001 is persistent in mysql.gtid_executed.