A brief introduction to the principle of MySQL two-stage submission process
MySQL uses two-phase commit to solve the problem of data consistency between binlog and InnoDB redo log.
Two-phase submission diagram:
Description of the principle of two-phase submission:
Stage 1:InnoDB redo log write disk, InnoDB transaction enters prepare state
Phase 2: if the previous prepare succeeds and binlog writes, then continue to persist the transaction log to binlog, and if the persistence is successful, then InnoDB
The transaction enters the commit state (actually writing a commit record in the redo log)
Note: a XID event is recorded at the end of each transaction binlog, indicating whether the transaction was committed successfully, that is, during the recovery process, binlog
Everything after the last XID event should be purge.