Said GTID - System variables associated with the GTID

gtid_next


When the transaction commits default, MySQL will be generated for a GTID. When played back on a transaction Slave node, it is used the GTID transaction generated on the Master node, and a Study of its origins gtid_next session-level system variables relevant.


If gtid_next value AUTOMATIC (its default value), when the enable binary logging, both in Slave or Master node node, the transaction will have to submit a new GTID. However, if a valid assignment will gtid_next GTID, then the next GTID GTID transaction is submitted, while the GTID will be added to the collection GTID gtid_executed. Slave node playback thread on the official use of this point, the assignment generated on the Master node GTID to @@ SESSION.gtid_next, then this GTID intact saved on the Slave nodes.



gtid_purged


Global system variable gtid_purged represents the set of all GTID been submitted, but in the binary log has cleared the transaction.


Global system variable gtid_purged is gtid_executed subset, a situation will cause a change in gtid_purged collection:

Disabling the binary log on · Slave nodes, with the playback thread submit copied affairs, gtid_purged change.

• When binary log file is cleared, gtid_purged change.

· @@ GLOBAL.gtid_purged when assigned, gtid_purged change.


It can be assembled by changing gtid_purged, to indicate that the transaction has been submitted, but was removed in the binary log file. When added to the collection gtid_purged GTID, but also to add this collection to GTID gtid_executed. By adding a backup read-only instance, the idea is the use of. In MySQL 5.7 version, can only collection is empty in gtid_executed, to set gtid_purged.



Each binary log files are recorded in a header Previous_gtids_log_event event, it represents the binary log files before all binary log files GTID set (i.e., the first N binary log files Previous_gtids_log_event, is equal to the N-1 binary log file Previous_gtids_log_event, and documents in the N-1 and the set of all Gtid_log_event).


gtid_executed and gtid_purged two global system variables, when MySQL is started by the oldest, and the latest binary log file Previous_gtids_log_event and Gtid_log_event initialized.


gtid_executed set is initialized as follows:


gtid_executed = new binary log file Previous_gtids_log_event + all the latest binary log file Gtid_log_event + system tables mysql.gtid_executed in GTID (but the collection does not contain GTID being executed with the GTID, namely @@ GLOBAL.gtid_owned).



gtid_purged collection is initialized idea is this:


The first equation:

GTID intersection of binary log files exist in the GTID, and cleared out the binary log file that gtids_in_binlog.


gtids_in_binlog = new binary log file Previous_gtids_log_event + new binary log file all Gtid_log_event


The second equation:

Binary log files exist in the GTID, namely gtids_in_binlog_not_purged.


gtids_in_binlog_not_purged = gtids_in_binlog - Previous_gtids_log_event oldest binary log file


Third equation:

There have been, but now no longer exists in the binary log file GTID, namely gtid_purged.


gtid_purged = gtid_executed - gtids_in_binlog_not_purged



By these three equations can be obtained:

gtid_purged = gtid_executed - gtids_in_binlog_not_purged = new binary log file Previous_gtids_log_event + new binary log file of all the Gtid_log_event + system tables mysql.gtid_executed in GTID - ((latest binary log file Previous_gtids_log_event + latest binary log files All Gtid_log_event) - Previous_gtids_log_event oldest binary log file)


That is, gtid_purged = system table mysql.gtid_executed the oldest GTID + binary log file Previous_gtids_log_event



A system parameter associated with the top two global system variable initialization is binlog_gtid_simple_recovery, if it is FALSE, the initialization of the two variables, MySQL will traverse all of the binary log file, not just the oldest, and the latest binary log files, this process may take a long time.

Guess you like

Origin blog.51cto.com/coveringindex/2424383