What’s Time Machine
• Rolling back instances/databases/tables to a snapshot
• Implement on Server-Level, so support all engines.
• By full image format binary logs
• Currently, it’s a feature inside mysqlbinlog tool (with--flashback
Why Time Machine
• Anyone maybe make mistakes, include DBA.
• After users mis-operate their data, of course, we can recovery it from
the last full backup set and binary logs.
• But if users’ database is too huge, it will cost so much time! And
usually, mis-operation just modify a few data, but we need to
recovery whole database.
How Time Machine Works
• As we know, if binlog_format is ROW (binlog-row-image=FULL in 5.6
and later), all columns’ values are store in the row event, so we can
get the data before mis-operation.
• Just do following things:
• Change Event Type, INSERT->DELETE, DELETE->INSERT
• For Update_Event, swapping the SET part and WHERE part
• Applying those events from the last one to the first one which mis-operation
• All the data will be recovered by inverse operations of mis-oprerations.
• Full DML supports
• Review table supports
• Because users may be want to check which parts of data be flashbacked.
• 10.0 supports
• It doesn’t support GTID now. So it doesn’t support 10.1 and later
• Adding GTID supports
• Deleting GTIDs which be flashbacked ? Unfriendly for replication.
• Adding new GTIDs for new events executed by time machine ?
• Adding DDL supports
• For ADD INDEX/COLUMN, or CREATE TABLE query, just drop the index, column,
table when running Flashback.
• For DROP INDEX/COLUMN, or DROP TABLE query, will copy or rename the old
table to a reserved database. When Flashback is running, I can drop new table,
and rename the saved old table to original database.
• For TRUNCATE table, I just rename old table to reserved database and create
a new empty table.
• Adding a new command for time machine or a script?