summaryrefslogtreecommitdiff
path: root/mysql-test/suite/wsrep
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-01-20 15:33:28 +0200
committerMonty <monty@mariadb.org>2017-01-20 15:33:28 +0200
commitd75d8631ed2d6af730931ea7079ec7e512e61796 (patch)
tree3b19d3e604354e3cba6b61468b00e9367cfc955a /mysql-test/suite/wsrep
parentb9631b46337b2ad76f0cc336cb2990e6bb8ad6f6 (diff)
downloadmariadb-git-d75d8631ed2d6af730931ea7079ec7e512e61796.tar.gz
[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:
Diffstat (limited to 'mysql-test/suite/wsrep')
-rw-r--r--mysql-test/suite/wsrep/r/binlog_format.result8
1 files changed, 4 insertions, 4 deletions
diff --git a/mysql-test/suite/wsrep/r/binlog_format.result b/mysql-test/suite/wsrep/r/binlog_format.result
index 1ca90bd626d..a7bae638012 100644
--- a/mysql-test/suite/wsrep/r/binlog_format.result
+++ b/mysql-test/suite/wsrep/r/binlog_format.result
@@ -8,20 +8,20 @@ Variable_name Value
binlog_format ROW
SET binlog_format=STATEMENT;
Warnings:
-Warning 1105 MariaDB Galera does not support binlog format: STATEMENT
+Warning 1105 MariaDB Galera and flashback does not support binlog format: STATEMENT
SHOW WARNINGS;
Level Code Message
-Warning 1105 MariaDB Galera does not support binlog format: STATEMENT
+Warning 1105 MariaDB Galera and flashback does not support binlog format: STATEMENT
SHOW VARIABLES LIKE 'binlog_format';
Variable_name Value
binlog_format STATEMENT
CREATE TABLE IF NOT EXISTS test.t1 AS SELECT * FROM information_schema.routines WHERE 1 = 0;
SET binlog_format=MIXED;
Warnings:
-Warning 1105 MariaDB Galera does not support binlog format: MIXED
+Warning 1105 MariaDB Galera and flashback does not support binlog format: MIXED
SHOW WARNINGS;
Level Code Message
-Warning 1105 MariaDB Galera does not support binlog format: MIXED
+Warning 1105 MariaDB Galera and flashback does not support binlog format: MIXED
SHOW VARIABLES LIKE 'binlog_format';
Variable_name Value
binlog_format MIXED