When MySQL uses the row format and the default binlog_row_image = full, the binlog records the complete data image before and after the update. Therefore, it is feasible to perform the undo operation based on the binlog in the row format. I tried this tool.
[GitHub Page] [linux binary file]
For example
./Binlog_undo-f/data/mysql/log-bin.000004-p 3958-o binlog. out
Scans all transactions from position 3958 to the end of/data/mysql/log-bin.000004, reverses all the transaction order and the statement order in each transaction, and reverse all the operations, reverses WRITE and DELETE, swaps the pre-and post-UPDATE images, and then writes the generated binlog file to binlog. out. Then you can use the mysqlbinlog tool to play back the binlog to cancel the operation.
This tool can be used to cancel the operations that are not synchronized to the slave after the master-slave switchover to avoid full reconstruction. It can also be used as a regret for misoperations.