1, Xid_event
When a transaction commits, either statement or the row format Binlog adds a xid_event as the end of the transaction. The event records the ID of the transaction. When MySQL is recovering from a crash, it decides whether to commit a transaction in the prepared state of the storage engine based on the conditions submitted in Binlog.
2, Rotate_event
A Binlog event is added to the end of the Rotate_event file currently in use when the Binlog file size reaches the value of the Max_binlog_size parameter setting or executes the flush Logs command, and the binlog switch occurs. Record the name and location of the next Binlog file into the event.
3, Stop_event
When the MySQL service stops, a stop_event event is added at the end of the current Binlog file to indicate that the database is stopped. The event includes only one public event header, no private event header, and no event body. Just the event type of the public event header is required.
4. Code
Xid_log_event::write Log_event::write_header wrapper_my_b_safe_write(file, (uchar*) &xid, sizeof(xid)) write_footer(file))//checksumRotate_log_event::write write_header(file, ROTATE_HEADER_LEN + ident_len) wrapper_my_b_safe_write(file, (uchar*) buf, ROTATE_HEADER_LEN) wrapper_my_b_safe_write(file, (uchar*) new_log_ident,(uint) ident_len) write_footer(file))
Parsing MySQL Binlog--(6) Xid_event, rotate_event and stop