mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
[MDEV-10570] Add Flashback support
==== Description ==== Flashback can rollback the instances/databases/tables to an old snapshot. It's implement on Server-Level by full image format binary logs (--binlog-row-image=FULL), so it supports all engines. Currently, it’s a feature inside mysqlbinlog tool (with --flashback arguments). Because the flashback binlog events will store in the memory, you should check if there is enough memory in your machine. ==== New Arguments to mysqlbinlog ==== --flashback (-B) It will let mysqlbinlog to work on FLASHBACK mode. ==== New Arguments to mysqld ==== --flashback Setup the server to use flashback. This enables binary log in row mode and will enable extra logging for DDL's needed by flashback feature ==== Example ==== I have a table "t" in database "test", we can compare the output with "--flashback" and without. #client/mysqlbinlog /data/mysqldata_10.0/binlog/mysql-bin.000001 -vv -d test -T t --start-datetime="2013-03-27 14:54:00" > /tmp/1.sql #client/mysqlbinlog /data/mysqldata_10.0/binlog/mysql-bin.000001 -vv -d test -T t --start-datetime="2013-03-27 14:54:00" -B > /tmp/2.sql Then, importing the output flashback file (/tmp/2.log), it can flashback your database/table to the special time (--start-datetime). And if you know the exact postion, "--start-postion" is also works, mysqlbinlog will output the flashback logs that can flashback to "--start-postion" position. ==== Implement ==== 1. As we know, if binlog_format is ROW (binlog-row-image=FULL in 10.1 and later), all columns value are store in the row event, so we can get the data before mis-operation. 2. Just do following things: 2.1 Change Event Type, INSERT->DELETE, DELETE->INSERT. For example: INSERT INTO t VALUES (...) ---> DELETE FROM t WHERE ... DELETE FROM t ... ---> INSERT INTO t VALUES (...) 2.2 For Update_Event, swapping the SET part and WHERE part. For example: UPDATE t SET cols1 = vals1 WHERE cols2 = vals2 ---> UPDATE t SET cols2 = vals2 WHERE cols1 = vals1 2.3 For Multi-Rows Event, reverse the rows sequence, from the last row to the first row. For example: DELETE FROM t WHERE id=1; DELETE FROM t WHERE id=2; ...; DELETE FROM t WHERE id=n; ---> DELETE FROM t WHERE id=n; ...; DELETE FROM t WHERE id=2; DELETE FROM t WHERE id=1; 2.4 Output those events from the last one to the first one which mis-operation happened. For example:
This commit is contained in:
@ -208,6 +208,9 @@ The following options may be given as the first argument:
|
||||
--extra-port=# Extra port number to use for tcp connections in a
|
||||
one-thread-per-connection manner. 0 means don't use
|
||||
another port
|
||||
--flashback Setup the server to use flashback. This enables binary
|
||||
log in row mode and will enable extra logging for DDL's
|
||||
needed by flashback feature
|
||||
--flush Flush MyISAM tables to disk between SQL commands
|
||||
--flush-time=# A dedicated thread is created to flush all tables at the
|
||||
given interval
|
||||
@ -1233,6 +1236,7 @@ explicit-defaults-for-timestamp FALSE
|
||||
external-locking FALSE
|
||||
extra-max-connections 1
|
||||
extra-port 0
|
||||
flashback FALSE
|
||||
flush FALSE
|
||||
flush-time 0
|
||||
ft-boolean-syntax + -><()~*:""&|
|
||||
|
Reference in New Issue
Block a user