SlideShare a Scribd company logo
1 of 30
Download to read offline
Hacking Session: undelete (and more) rows
from the binary log
Percona Live Europe Amsterdam 2015 Frédéric -lefred- Descamps
Who am I ?
●
Frédéric Descamps
●
@lefred - follow me on twitter if you want ;-)
●
http://about.me/lefred
●
Working for Percona since 2011
●
Managing MySQL since 3.23
●
devops believer
Why ?
Because of Scott Noyes' blog post :
http://thenoyes.com/littlenoise/?p=307
●
Because it's faster than point-in-time
recovery
●
Because I didn't remember the awk script
in Scott's blog post
Requirements
●
Have the binary logs in ROW format
●
Have binlog_row_image set to FULL
●
Have access to the binary logs
●
Have access to MySQL
●
Have access to the MySQL source code [not mandatory]
●
Have a brain and being able to use it ;-)
Percona Live Europe Amsterdam 2015
Point-in-Time Recovery
Usually when we need to «undo» even one single statement, we
need to perform a point-in-time recovery
●
restore the last backup (full or several incrementals)
●
then replay some binary logs (and it can be a bunch of them!)
●
this is a very slow operation and while the binary logs are
replayed, usually everything needs to be stopped.
Percona Live Europe Amsterdam 2015
Let's hack together a quicker process
Ready ?
Let's delete a row
mysql> select @@version, @@version_comment;
+------------+------------------------------+
| @@version | @@version_comment |
+------------+------------------------------+
| 5.6.22-log | MySQL Community Server (GPL) |
+------------+------------------------------+
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 2 | Liz | 2 | 24 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
4 rows in set (0.00 sec)
Percona Live Europe Amsterdam 2015
Let's delete a row (2)
mysql> delete from community_dinner where id=2;
Query OK, 1 row affected (0.05 sec)
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
3 rows in set (0.00 sec)
Percona Live Europe Amsterdam 2015
Let's find the event in the binary log
mysql> show master statusG
*************************** 1. row ***************************
File: mysql-bin.000018
Position: 907
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
mysql> show binlog events in 'mysql-bin.000018';
+------------------+-----+-------------+-----------+-------------+---------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+-------------+-----------+------------+----------------------------+
| mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... |
| mysql-bin.000018 | 120 | Query | 1 | 220 | create ... |
| mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; |
| mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN |
| mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ |
| mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN |
| mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ |
+------------------+-----+-------------+-----------+------------+====------------------------+
Percona Live Europe Amsterdam 2015
Let's find the event in the binary log
mysql> show master statusG
*************************** 1. row ***************************
File: mysql-bin.000018
Position: 907
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
mysql> show binlog events in 'mysql-bin.000018';
+------------------+-----+-------------+-----------+-------------+---------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+-------------+-----------+------------+----------------------------+
| mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... |
| mysql-bin.000018 | 120 | Query | 1 | 220 | create ... |
| mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; |
| mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN |
| mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ |
| mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN |
| mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ |
+------------------+-----+-------------+-----------+------------+====------------------------+
The event we are looking for
Percona Live Europe Amsterdam 2015
binary log's event content
# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#141221 21:20:55 server id 1 end_log_pos 120 CRC32 0xff8913a3 Start: binlog v 4, server v
5.6.22-log created 141221 21:20:55 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
pyuXVA8BAAAAdAAAAHgAAAABAAQANS42LjIyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACnK5dUEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAaMT
if8=
'/*!*/;
# at 824
#150103 16:55:49 server id 1 end_log_pos 876 CRC32 0xaac329ee Delete_rows: table id 76 flags:
STMT_END_F
BINLOG '
BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
Percona Live Europe Amsterdam 2015
binary log's event content
# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#141221 21:20:55 server id 1 end_log_pos 120 CRC32 0xff8913a3 Start: binlog v 4, server v
5.6.22-log created 141221 21:20:55 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
pyuXVA8BAAAAdAAAAHgAAAABAAQANS42LjIyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACnK5dUEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAaMT
if8=
'/*!*/;
# at 824
#150103 16:55:49 server id 1 end_log_pos 876 CRC32 0xaac329ee Delete_rows: table id 76 flags:
STMT_END_F
BINLOG '
BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
Percona Live Europe Amsterdam 2015
binary log's event content decoded
...
BINLOG '
BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
'/*!*/;
...
●
Let's check from the source the type code:
https://github.com/mysql/mysql-server/blob/5.6/sql/log_event.h
WRITE_ROWS_EVENT = 30,
UPDATE_ROWS_EVENT = 31,
DELETE_ROWS_EVENT = 32,
Percona Live Europe Amsterdam 2015
binary log's event content decoded
...
BINLOG '
BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
'/*!*/;
...
●
Let's check from the source the type code:
https://github.com/mysql/mysql-server/blob/5.6/sql/log_event.h
WRITE_ROWS_EVENT = 30,
UPDATE_ROWS_EVENT = 31,
DELETE_ROWS_EVENT = 32,
MySQL 5.5 and MariaDB use V1:
WRITE_ROWS_EVENT_V1 = 23,
UPDATE_ROWS_EVENT_V1 = 24,
DELETE_ROWS_EVENT_V1 = 25,
Percona Live Europe Amsterdam 2015
binary log's event content decoded
# python -c "print hex(32)"
0x20
●
Again from the source we can find the event type's offset
#define EVENT_TYPE_OFFSET 4
# python -c "import base64; print ord(base64.b64decode(b'BRGoVCABA
AAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAA
AA7inDqg==')[4])"
32
●
This is exactly the event we were looking for !!
Percona Live Europe Amsterdam 2015
rebuild a new binlog event
●
Now we can rebuild a new event by replacing x32 by x30
# python
>>> import base64
>>>
data=base64.b64decode(b'BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYA
AAA7inDqg==')
>>> data
'x05x11xa8T x01x00x00x004x00x00x00lx03x00x00x00x00L
x00x00x00x00x00x01x00x02x00x04xffxf0x02x00x00x00x03
Lizx02x00x00x00x18x00x00x00xee)xc3xaa'
>>> hex(30)
'0x1e'
>>> data2=base64.b64encode("x05x11xa8Tx1ex01x00x00x004x00x00x00lx03x00
x00x00x00Lx00x00x00x00x00x01x00x02x00x04xffxf0x02x00x00x00x03
Lizx02x00x00x00x18x00x00x00xee)xc3xaa")
>>> data2
'BRGoVDABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg=='
●
Let's compare the two lines:
BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
BRGoVB4BAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==
Percona Live Europe Amsterdam 2015
rebuild a new binlog event & replay it
●
ready to replay ?
●# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 | 
> sed s/BRGoVCAB/BRGoVB4B/ | mysql
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
3 rows in set (0.00 sec)
Percona Live Europe Amsterdam 2015
rebuild a new binlog event & replay it
●
ready to replay ?
●# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 | 
sed s/BRGoVCAB/BRGoVB4B/ | mysql
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
3 rows in set (0.00 sec)
uuh ? did it fail ?
Percona Live Europe Amsterdam 2015
find what to replay
mysql> show binlog events in 'mysql-bin.000018';
+------------------+-----+-------------+-----------+-------------+---------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+-------------+-----------+------------+----------------------------+
| mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... |
| mysql-bin.000018 | 120 | Query | 1 | 220 | create ... |
| mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; |
| mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN |
| mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ |
| mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN |
| mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu|
| mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E|
| mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ |
+------------------+-----+-------------+-----------+------------+====------------------------+
●
We need to replay more, from the BEGIN to the COMMIT
Percona Live Europe Amsterdam 2015
replay it, 2nd try
●
ready to replay, again ?
●# mysqlbinlog mysql-bin.000018 -j 684 --stop-position=907 | 
> sed s/BRGoVCAB/BRGoVB4B/ | mysql
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 2 | Liz | 2 | 24 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
4 rows in set (0.00 sec)
Percona Live Europe Amsterdam 2015
replay it, 2nd try
●
ready to replay, again ?
●# mysqlbinlog mysql-bin.000018 -j 684 --stop-position=907 | 
> sed s/BRGoVCAB/BRGoVB4B/ | mysql
mysql> select * from fosdem.community_dinner;
+----+--------+--------+-------+
| id | name | pizzas | beers |
+----+--------+--------+-------+
| 1 | dim0 | 99 | 99 |
| 2 | Liz | 2 | 24 |
| 3 | Kenny | 12 | 32 |
| 4 | lefred | 10 | 10 |
+----+--------+--------+-------+
4 rows in set (0.00 sec)
Percona Live Europe Amsterdam 2015
More ?
●
With the same kind of technique, we can also:
– delete rows that were inserted (sql injection?)
– un-update modified rows (more complicated)
●
I've created a script that automates all that: MyUndelete
Percona Live Europe Amsterdam 2015
MyUndelete : «un-insert»
●
We can delete an INSERT
Percona Live Europe Amsterdam 2015
# ./MyUndelete.py -s 41989 -e 42207 -i -b mysql-bin.000004
*** WARNING *** USE WITH CARE ****
Binlog file is /var/lib/mysql/mysqld-bin.000004
Start Position file is 41989
End Postision file is 42207
We also look to undo INSERTs
Event type ('x1e') is an insert v2
Ready to revert the statement ? [y/n]
y
Done... I hope it worked ;)
MyUndelete : «un-update»
●
This is a bit more difficult as we need to find the lenght of the
record to be able to split both records and rebuild a working
binary event
Percona Live Europe Amsterdam 2015
mysql> select * from community_dinner;
+----+-------+--------+-------+
| id | name | pizzas | beers |
+----+-------+--------+-------+
| 1 | fred | 3 | 3 |
| 2 | lizz | 2 | 10 |
| 3 | dimi | 99 | 99 |
| 4 | kenny | 20 | 20 |
+----+-------+--------+-------+
MyUndelete : «un-update» (2)
Percona Live Europe Amsterdam 2015
mysql> update community_dinner set beers=0 where id=3;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from community_dinner;
+----+-------+--------+-------+
| id | name | pizzas | beers |
+----+-------+--------+-------+
| 1 | fred | 3 | 3 |
| 2 | lizz | 2 | 10 |
| 3 | dimi | 99 | 0 |
| 4 | kenny | 20 | 20 |
+----+-------+--------+-------+
4 rows in set (0.00 sec)
MyUndelete : «un-update» (3)
Percona Live Europe Amsterdam 2015
mysql> show binlog events in 'mysqld-bin.000018';
...
| mysqld-bin.000018 | 1145 | Query | 1 | 1219 | BEGIN |
| mysqld-bin.000018 | 1219 | Table_map | 1 | 1285 | table_id: 70
(fosdem.community_dinner) |
| mysqld-bin.000018 | 1285 | Update_rows | 1 | 1357 | table_id: 70 flags: STMT_END_F
| mysqld-bin.000018 | 1357 | Xid | 1 | 1388 | COMMIT /* xid=44 */
...
# ./MyUndelete.py -s 1145 -e 1388 -u -b /var/lib/mysql/mysqld-bin.000018
*** WARNING *** USE WITH CARE ****
Binlog file is /var/lib/mysql/mysqld-bin.000018
Start Position file is 1145
End Postision file is 1357
Event type ('x1f') is an update v2
We got an update!!
Ready to revert the statement ? [y/n]
y
Sending to mysql...
Done... I hope it worked ;)
MyUndelete : «un-update» (4)
Percona Live Europe Amsterdam 2015
mysql> select * from community_dinner;
+----+-------+--------+-------+
| id | name | pizzas | beers |
+----+-------+--------+-------+
| 1 | fred | 3 | 3 |
| 2 | lizz | 2 | 10 |
| 3 | dimi | 99 | 99 |
| 4 | kenny | 20 | 20 |
+----+-------+--------+-------+
Resources
●
Oracle MySQL Source code — https://github.com/mysql/mysql-server
●
MariaDB Source Code — https://github.com/MariaDB/server
●
Scott Noyes Blog Post - http://thenoyes.com/littlenoise/?p=307
●
MyUndelete on github — https://github.com/lefred/MyUndelete
Percona Live Europe Amsterdam 2015
Related topic
●
MySQL released «Binary Log API» that could be use to decode
in a better way the binary logs
– http://mysqlhighavailability.com/mysql-binlog-events-reading-and-handling-
information-from-your-binary-log/
– http://mysqlhighavailability.com/mysql-binlog-events-use-case-and-examples/
●
Jeremy Cole wrote a Ruby Library to also parse binary logs
– https://github.com/jeremycole/mysql_binlog
Percona Live Europe Amsterdam 2015
Thank you
Questions ?
Percona Live Europe Amsterdam 2015

More Related Content

What's hot

Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security InternalsOpersys inc.
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakAbraham Aranguren
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務Bo-Yi Wu
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1Jean-François Gagné
 
Redis Introduction
Redis IntroductionRedis Introduction
Redis IntroductionAlex Su
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicJoseph Lu
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in AndroidOpersys inc.
 
Advanced c programming in Linux
Advanced c programming in Linux Advanced c programming in Linux
Advanced c programming in Linux Mohammad Golyani
 
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...ScyllaDB
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQLEDB
 
macOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightmacOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightCsaba Fitzl
 
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCsw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCanSecWest
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 
Social Engineering the Windows Kernel by James Forshaw
Social Engineering the Windows Kernel by James ForshawSocial Engineering the Windows Kernel by James Forshaw
Social Engineering the Windows Kernel by James ForshawShakacon
 
Reverse Mapping (rmap) in Linux Kernel
Reverse Mapping (rmap) in Linux KernelReverse Mapping (rmap) in Linux Kernel
Reverse Mapping (rmap) in Linux KernelAdrian Huang
 
IBM Spectrum Scale Secure- Secure Data in Motion and Rest
IBM Spectrum Scale Secure- Secure Data in Motion and RestIBM Spectrum Scale Secure- Secure Data in Motion and Rest
IBM Spectrum Scale Secure- Secure Data in Motion and RestSandeep Patil
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web ServicesXXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web ServicesAbraham Aranguren
 
Linux Kernel Init Process
Linux Kernel Init ProcessLinux Kernel Init Process
Linux Kernel Init ProcessKernel TLV
 
Reverse Engineering of Rocket Chip
Reverse Engineering of Rocket ChipReverse Engineering of Rocket Chip
Reverse Engineering of Rocket ChipRISC-V International
 

What's hot (20)

Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1
 
Redis Introduction
Redis IntroductionRedis Introduction
Redis Introduction
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panic
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Advanced c programming in Linux
Advanced c programming in Linux Advanced c programming in Linux
Advanced c programming in Linux
 
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
macOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightmacOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain Sight
 
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCsw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Social Engineering the Windows Kernel by James Forshaw
Social Engineering the Windows Kernel by James ForshawSocial Engineering the Windows Kernel by James Forshaw
Social Engineering the Windows Kernel by James Forshaw
 
Reverse Mapping (rmap) in Linux Kernel
Reverse Mapping (rmap) in Linux KernelReverse Mapping (rmap) in Linux Kernel
Reverse Mapping (rmap) in Linux Kernel
 
IBM Spectrum Scale Secure- Secure Data in Motion and Rest
IBM Spectrum Scale Secure- Secure Data in Motion and RestIBM Spectrum Scale Secure- Secure Data in Motion and Rest
IBM Spectrum Scale Secure- Secure Data in Motion and Rest
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web ServicesXXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
 
Linux Kernel Init Process
Linux Kernel Init ProcessLinux Kernel Init Process
Linux Kernel Init Process
 
Reverse Engineering of Rocket Chip
Reverse Engineering of Rocket ChipReverse Engineering of Rocket Chip
Reverse Engineering of Rocket Chip
 
RDMA on ARM
RDMA on ARMRDMA on ARM
RDMA on ARM
 

Viewers also liked

Webinar manage MySQL like a devops sysadmin
Webinar manage MySQL like a devops sysadminWebinar manage MySQL like a devops sysadmin
Webinar manage MySQL like a devops sysadminFrederic Descamps
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationFrederic Descamps
 
The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016sys army
 
A Simple Multi-player Video Game Framework for Experimenting and Teaching C...
A Simple Multi-player Video Game  Framework for Experimenting  and Teaching C...A Simple Multi-player Video Game  Framework for Experimenting  and Teaching C...
A Simple Multi-player Video Game Framework for Experimenting and Teaching C...Mindtrek
 
Database Tendency
Database TendencyDatabase Tendency
Database Tendencygrandis_au
 
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...Mindtrek
 
Inspecting a multi everything linux system (plmce2k14)
Inspecting a multi everything linux system (plmce2k14)Inspecting a multi everything linux system (plmce2k14)
Inspecting a multi everything linux system (plmce2k14)Frederic Descamps
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFrederic Descamps
 
Plmce2k15 15 tips galera cluster
Plmce2k15   15 tips galera clusterPlmce2k15   15 tips galera cluster
Plmce2k15 15 tips galera clusterFrederic Descamps
 
Loadays managing my sql with percona toolkit
Loadays managing my sql with percona toolkitLoadays managing my sql with percona toolkit
Loadays managing my sql with percona toolkitFrederic Descamps
 
My first moments with MongoDB
My first moments with MongoDBMy first moments with MongoDB
My first moments with MongoDBColin Charles
 
MariaDB Server & MySQL Security Essentials 2016
MariaDB Server & MySQL Security Essentials 2016MariaDB Server & MySQL Security Essentials 2016
MariaDB Server & MySQL Security Essentials 2016Colin Charles
 
MariaDB Server Compatibility with MySQL
MariaDB Server Compatibility with MySQLMariaDB Server Compatibility with MySQL
MariaDB Server Compatibility with MySQLColin Charles
 
Securing your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server dataSecuring your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server dataColin Charles
 
Percon XtraDB Cluster in a nutshell
Percon XtraDB Cluster in a nutshellPercon XtraDB Cluster in a nutshell
Percon XtraDB Cluster in a nutshellFrederic Descamps
 
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...Frederic Descamps
 
In-memory Database and MySQL Cluster
In-memory Database and MySQL ClusterIn-memory Database and MySQL Cluster
In-memory Database and MySQL Clustergrandis_au
 
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Frederic Descamps
 
Pluk2011 deploy-mysql-like-a-devops-sysadmin
Pluk2011 deploy-mysql-like-a-devops-sysadminPluk2011 deploy-mysql-like-a-devops-sysadmin
Pluk2011 deploy-mysql-like-a-devops-sysadminFrederic Descamps
 

Viewers also liked (20)

Webinar manage MySQL like a devops sysadmin
Webinar manage MySQL like a devops sysadminWebinar manage MySQL like a devops sysadmin
Webinar manage MySQL like a devops sysadmin
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016
 
A Simple Multi-player Video Game Framework for Experimenting and Teaching C...
A Simple Multi-player Video Game  Framework for Experimenting  and Teaching C...A Simple Multi-player Video Game  Framework for Experimenting  and Teaching C...
A Simple Multi-player Video Game Framework for Experimenting and Teaching C...
 
Database Tendency
Database TendencyDatabase Tendency
Database Tendency
 
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...
Otto Kekäläinen - Forking in Open Source: Case Study of MySQL/MariaDB - Mindt...
 
Oss4b - pxc introduction
Oss4b   - pxc introductionOss4b   - pxc introduction
Oss4b - pxc introduction
 
Inspecting a multi everything linux system (plmce2k14)
Inspecting a multi everything linux system (plmce2k14)Inspecting a multi everything linux system (plmce2k14)
Inspecting a multi everything linux system (plmce2k14)
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkit
 
Plmce2k15 15 tips galera cluster
Plmce2k15   15 tips galera clusterPlmce2k15   15 tips galera cluster
Plmce2k15 15 tips galera cluster
 
Loadays managing my sql with percona toolkit
Loadays managing my sql with percona toolkitLoadays managing my sql with percona toolkit
Loadays managing my sql with percona toolkit
 
My first moments with MongoDB
My first moments with MongoDBMy first moments with MongoDB
My first moments with MongoDB
 
MariaDB Server & MySQL Security Essentials 2016
MariaDB Server & MySQL Security Essentials 2016MariaDB Server & MySQL Security Essentials 2016
MariaDB Server & MySQL Security Essentials 2016
 
MariaDB Server Compatibility with MySQL
MariaDB Server Compatibility with MySQLMariaDB Server Compatibility with MySQL
MariaDB Server Compatibility with MySQL
 
Securing your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server dataSecuring your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server data
 
Percon XtraDB Cluster in a nutshell
Percon XtraDB Cluster in a nutshellPercon XtraDB Cluster in a nutshell
Percon XtraDB Cluster in a nutshell
 
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
 
In-memory Database and MySQL Cluster
In-memory Database and MySQL ClusterIn-memory Database and MySQL Cluster
In-memory Database and MySQL Cluster
 
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
 
Pluk2011 deploy-mysql-like-a-devops-sysadmin
Pluk2011 deploy-mysql-like-a-devops-sysadminPluk2011 deploy-mysql-like-a-devops-sysadmin
Pluk2011 deploy-mysql-like-a-devops-sysadmin
 

Similar to Undelete (and more) rows from the binary log

Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicSaewoong Lee
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite PluginsSveta Smirnova
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part IIIAlkin Tezuysal
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLPadraig O'Sullivan
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLRonald Bradford
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorialEueung Mulyana
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGIMike Pittaro
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Dan Radez
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
MySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkMySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkLouis liu
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.pptKISHOYIANKISH
 

Similar to Undelete (and more) rows from the binary log (20)

MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_public
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part III
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQL
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQL
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorial
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
MySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkMySQL Tokudb engine benchmark
MySQL Tokudb engine benchmark
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
 

More from Frederic Descamps

MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...Frederic Descamps
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionFrederic Descamps
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsFrederic Descamps
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfFrederic Descamps
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8Frederic Descamps
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022Frederic Descamps
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodeFrederic Descamps
 
Percona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemPercona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemFrederic Descamps
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesFrederic Descamps
 
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database SystemLinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database SystemFrederic Descamps
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsFrederic Descamps
 
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
Pi Day 2022 -  from IoT to MySQL HeatWave Database ServicePi Day 2022 -  from IoT to MySQL HeatWave Database Service
Pi Day 2022 - from IoT to MySQL HeatWave Database ServiceFrederic Descamps
 
Confoo 2022 - le cycle d'une instance MySQL
Confoo 2022  - le cycle d'une instance MySQLConfoo 2022  - le cycle d'une instance MySQL
Confoo 2022 - le cycle d'une instance MySQLFrederic Descamps
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...Frederic Descamps
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Frederic Descamps
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Frederic Descamps
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021Frederic Descamps
 
Deploying Magento on OCI with MDS
Deploying Magento on OCI with MDSDeploying Magento on OCI with MDS
Deploying Magento on OCI with MDSFrederic Descamps
 

More from Frederic Descamps (20)

MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
Percona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemPercona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database System
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database SystemLinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
Pi Day 2022 -  from IoT to MySQL HeatWave Database ServicePi Day 2022 -  from IoT to MySQL HeatWave Database Service
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
 
Confoo 2022 - le cycle d'une instance MySQL
Confoo 2022  - le cycle d'une instance MySQLConfoo 2022  - le cycle d'une instance MySQL
Confoo 2022 - le cycle d'une instance MySQL
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
Deploying Magento on OCI with MDS
Deploying Magento on OCI with MDSDeploying Magento on OCI with MDS
Deploying Magento on OCI with MDS
 
MySQL Router REST API
MySQL Router REST APIMySQL Router REST API
MySQL Router REST API
 

Recently uploaded

S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 

Recently uploaded (20)

S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 

Undelete (and more) rows from the binary log

  • 1. Hacking Session: undelete (and more) rows from the binary log Percona Live Europe Amsterdam 2015 Frédéric -lefred- Descamps
  • 2. Who am I ? ● Frédéric Descamps ● @lefred - follow me on twitter if you want ;-) ● http://about.me/lefred ● Working for Percona since 2011 ● Managing MySQL since 3.23 ● devops believer
  • 3. Why ? Because of Scott Noyes' blog post : http://thenoyes.com/littlenoise/?p=307 ● Because it's faster than point-in-time recovery ● Because I didn't remember the awk script in Scott's blog post
  • 4. Requirements ● Have the binary logs in ROW format ● Have binlog_row_image set to FULL ● Have access to the binary logs ● Have access to MySQL ● Have access to the MySQL source code [not mandatory] ● Have a brain and being able to use it ;-) Percona Live Europe Amsterdam 2015
  • 5. Point-in-Time Recovery Usually when we need to «undo» even one single statement, we need to perform a point-in-time recovery ● restore the last backup (full or several incrementals) ● then replay some binary logs (and it can be a bunch of them!) ● this is a very slow operation and while the binary logs are replayed, usually everything needs to be stopped. Percona Live Europe Amsterdam 2015
  • 6. Let's hack together a quicker process Ready ?
  • 7. Let's delete a row mysql> select @@version, @@version_comment; +------------+------------------------------+ | @@version | @@version_comment | +------------+------------------------------+ | 5.6.22-log | MySQL Community Server (GPL) | +------------+------------------------------+ mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 2 | Liz | 2 | 24 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 4 rows in set (0.00 sec) Percona Live Europe Amsterdam 2015
  • 8. Let's delete a row (2) mysql> delete from community_dinner where id=2; Query OK, 1 row affected (0.05 sec) mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 3 rows in set (0.00 sec) Percona Live Europe Amsterdam 2015
  • 9. Let's find the event in the binary log mysql> show master statusG *************************** 1. row *************************** File: mysql-bin.000018 Position: 907 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: 1 row in set (0.00 sec) mysql> show binlog events in 'mysql-bin.000018'; +------------------+-----+-------------+-----------+-------------+---------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +------------------+-----+-------------+-----------+------------+----------------------------+ | mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... | | mysql-bin.000018 | 120 | Query | 1 | 220 | create ... | | mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; | | mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN | | mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ | | mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN | | mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ | +------------------+-----+-------------+-----------+------------+====------------------------+ Percona Live Europe Amsterdam 2015
  • 10. Let's find the event in the binary log mysql> show master statusG *************************** 1. row *************************** File: mysql-bin.000018 Position: 907 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: 1 row in set (0.00 sec) mysql> show binlog events in 'mysql-bin.000018'; +------------------+-----+-------------+-----------+-------------+---------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +------------------+-----+-------------+-----------+------------+----------------------------+ | mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... | | mysql-bin.000018 | 120 | Query | 1 | 220 | create ... | | mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; | | mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN | | mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ | | mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN | | mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ | +------------------+-----+-------------+-----------+------------+====------------------------+ The event we are looking for Percona Live Europe Amsterdam 2015
  • 11. binary log's event content # mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #141221 21:20:55 server id 1 end_log_pos 120 CRC32 0xff8913a3 Start: binlog v 4, server v 5.6.22-log created 141221 21:20:55 at startup # Warning: this binlog is either in use or was not closed properly. ROLLBACK/*!*/; BINLOG ' pyuXVA8BAAAAdAAAAHgAAAABAAQANS42LjIyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACnK5dUEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAaMT if8= '/*!*/; # at 824 #150103 16:55:49 server id 1 end_log_pos 876 CRC32 0xaac329ee Delete_rows: table id 76 flags: STMT_END_F BINLOG ' BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== '/*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; Percona Live Europe Amsterdam 2015
  • 12. binary log's event content # mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #141221 21:20:55 server id 1 end_log_pos 120 CRC32 0xff8913a3 Start: binlog v 4, server v 5.6.22-log created 141221 21:20:55 at startup # Warning: this binlog is either in use or was not closed properly. ROLLBACK/*!*/; BINLOG ' pyuXVA8BAAAAdAAAAHgAAAABAAQANS42LjIyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACnK5dUEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAaMT if8= '/*!*/; # at 824 #150103 16:55:49 server id 1 end_log_pos 876 CRC32 0xaac329ee Delete_rows: table id 76 flags: STMT_END_F BINLOG ' BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== '/*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; Percona Live Europe Amsterdam 2015
  • 13. binary log's event content decoded ... BINLOG ' BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== '/*!*/; ... ● Let's check from the source the type code: https://github.com/mysql/mysql-server/blob/5.6/sql/log_event.h WRITE_ROWS_EVENT = 30, UPDATE_ROWS_EVENT = 31, DELETE_ROWS_EVENT = 32, Percona Live Europe Amsterdam 2015
  • 14. binary log's event content decoded ... BINLOG ' BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== '/*!*/; ... ● Let's check from the source the type code: https://github.com/mysql/mysql-server/blob/5.6/sql/log_event.h WRITE_ROWS_EVENT = 30, UPDATE_ROWS_EVENT = 31, DELETE_ROWS_EVENT = 32, MySQL 5.5 and MariaDB use V1: WRITE_ROWS_EVENT_V1 = 23, UPDATE_ROWS_EVENT_V1 = 24, DELETE_ROWS_EVENT_V1 = 25, Percona Live Europe Amsterdam 2015
  • 15. binary log's event content decoded # python -c "print hex(32)" 0x20 ● Again from the source we can find the event type's offset #define EVENT_TYPE_OFFSET 4 # python -c "import base64; print ord(base64.b64decode(b'BRGoVCABA AAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAA AA7inDqg==')[4])" 32 ● This is exactly the event we were looking for !! Percona Live Europe Amsterdam 2015
  • 16. rebuild a new binlog event ● Now we can rebuild a new event by replacing x32 by x30 # python >>> import base64 >>> data=base64.b64decode(b'BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYA AAA7inDqg==') >>> data 'x05x11xa8T x01x00x00x004x00x00x00lx03x00x00x00x00L x00x00x00x00x00x01x00x02x00x04xffxf0x02x00x00x00x03 Lizx02x00x00x00x18x00x00x00xee)xc3xaa' >>> hex(30) '0x1e' >>> data2=base64.b64encode("x05x11xa8Tx1ex01x00x00x004x00x00x00lx03x00 x00x00x00Lx00x00x00x00x00x01x00x02x00x04xffxf0x02x00x00x00x03 Lizx02x00x00x00x18x00x00x00xee)xc3xaa") >>> data2 'BRGoVDABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg==' ● Let's compare the two lines: BRGoVCABAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== BRGoVB4BAAAANAAAAGwDAAAAAEwAAAAAAAEAAgAE//ACAAAAA0xpegIAAAAYAAAA7inDqg== Percona Live Europe Amsterdam 2015
  • 17. rebuild a new binlog event & replay it ● ready to replay ? ●# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 | > sed s/BRGoVCAB/BRGoVB4B/ | mysql mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 3 rows in set (0.00 sec) Percona Live Europe Amsterdam 2015
  • 18. rebuild a new binlog event & replay it ● ready to replay ? ●# mysqlbinlog mysql-bin.000018 -j 824 --stop-position=876 | sed s/BRGoVCAB/BRGoVB4B/ | mysql mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 3 rows in set (0.00 sec) uuh ? did it fail ? Percona Live Europe Amsterdam 2015
  • 19. find what to replay mysql> show binlog events in 'mysql-bin.000018'; +------------------+-----+-------------+-----------+-------------+---------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +------------------+-----+-------------+-----------+------------+----------------------------+ | mysql-bin.000018 | 4 | Format_desc | 1 | 120 | Server ... | | mysql-bin.000018 | 120 | Query | 1 | 220 | create ... | | mysql-bin.000018 | 220 | Query | 1 | 404 | use `fosdem`; | | mysql-bin.000018 | 404 | Query | 1 | 478 | BEGIN | | mysql-bin.000018 | 478 | Table_map | 1 | 544 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 544 | Write_rows | 1 | 653 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 653 | Xid | 1 | 684 | COMMIT /* xid=32 */ | | mysql-bin.000018 | 684 | Query | 1 | 758 | BEGIN | | mysql-bin.000018 | 758 | Table_map | 1 | 824 | table_id: 76 (fosdem.commu| | mysql-bin.000018 | 824 | Delete_rows | 1 | 876 | table_id: 76 flags: STMT_E| | mysql-bin.000018 | 876 | Xid | 1 | 907 | COMMIT /* xid=34 */ | +------------------+-----+-------------+-----------+------------+====------------------------+ ● We need to replay more, from the BEGIN to the COMMIT Percona Live Europe Amsterdam 2015
  • 20. replay it, 2nd try ● ready to replay, again ? ●# mysqlbinlog mysql-bin.000018 -j 684 --stop-position=907 | > sed s/BRGoVCAB/BRGoVB4B/ | mysql mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 2 | Liz | 2 | 24 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 4 rows in set (0.00 sec) Percona Live Europe Amsterdam 2015
  • 21. replay it, 2nd try ● ready to replay, again ? ●# mysqlbinlog mysql-bin.000018 -j 684 --stop-position=907 | > sed s/BRGoVCAB/BRGoVB4B/ | mysql mysql> select * from fosdem.community_dinner; +----+--------+--------+-------+ | id | name | pizzas | beers | +----+--------+--------+-------+ | 1 | dim0 | 99 | 99 | | 2 | Liz | 2 | 24 | | 3 | Kenny | 12 | 32 | | 4 | lefred | 10 | 10 | +----+--------+--------+-------+ 4 rows in set (0.00 sec) Percona Live Europe Amsterdam 2015
  • 22. More ? ● With the same kind of technique, we can also: – delete rows that were inserted (sql injection?) – un-update modified rows (more complicated) ● I've created a script that automates all that: MyUndelete Percona Live Europe Amsterdam 2015
  • 23. MyUndelete : «un-insert» ● We can delete an INSERT Percona Live Europe Amsterdam 2015 # ./MyUndelete.py -s 41989 -e 42207 -i -b mysql-bin.000004 *** WARNING *** USE WITH CARE **** Binlog file is /var/lib/mysql/mysqld-bin.000004 Start Position file is 41989 End Postision file is 42207 We also look to undo INSERTs Event type ('x1e') is an insert v2 Ready to revert the statement ? [y/n] y Done... I hope it worked ;)
  • 24. MyUndelete : «un-update» ● This is a bit more difficult as we need to find the lenght of the record to be able to split both records and rebuild a working binary event Percona Live Europe Amsterdam 2015 mysql> select * from community_dinner; +----+-------+--------+-------+ | id | name | pizzas | beers | +----+-------+--------+-------+ | 1 | fred | 3 | 3 | | 2 | lizz | 2 | 10 | | 3 | dimi | 99 | 99 | | 4 | kenny | 20 | 20 | +----+-------+--------+-------+
  • 25. MyUndelete : «un-update» (2) Percona Live Europe Amsterdam 2015 mysql> update community_dinner set beers=0 where id=3; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from community_dinner; +----+-------+--------+-------+ | id | name | pizzas | beers | +----+-------+--------+-------+ | 1 | fred | 3 | 3 | | 2 | lizz | 2 | 10 | | 3 | dimi | 99 | 0 | | 4 | kenny | 20 | 20 | +----+-------+--------+-------+ 4 rows in set (0.00 sec)
  • 26. MyUndelete : «un-update» (3) Percona Live Europe Amsterdam 2015 mysql> show binlog events in 'mysqld-bin.000018'; ... | mysqld-bin.000018 | 1145 | Query | 1 | 1219 | BEGIN | | mysqld-bin.000018 | 1219 | Table_map | 1 | 1285 | table_id: 70 (fosdem.community_dinner) | | mysqld-bin.000018 | 1285 | Update_rows | 1 | 1357 | table_id: 70 flags: STMT_END_F | mysqld-bin.000018 | 1357 | Xid | 1 | 1388 | COMMIT /* xid=44 */ ... # ./MyUndelete.py -s 1145 -e 1388 -u -b /var/lib/mysql/mysqld-bin.000018 *** WARNING *** USE WITH CARE **** Binlog file is /var/lib/mysql/mysqld-bin.000018 Start Position file is 1145 End Postision file is 1357 Event type ('x1f') is an update v2 We got an update!! Ready to revert the statement ? [y/n] y Sending to mysql... Done... I hope it worked ;)
  • 27. MyUndelete : «un-update» (4) Percona Live Europe Amsterdam 2015 mysql> select * from community_dinner; +----+-------+--------+-------+ | id | name | pizzas | beers | +----+-------+--------+-------+ | 1 | fred | 3 | 3 | | 2 | lizz | 2 | 10 | | 3 | dimi | 99 | 99 | | 4 | kenny | 20 | 20 | +----+-------+--------+-------+
  • 28. Resources ● Oracle MySQL Source code — https://github.com/mysql/mysql-server ● MariaDB Source Code — https://github.com/MariaDB/server ● Scott Noyes Blog Post - http://thenoyes.com/littlenoise/?p=307 ● MyUndelete on github — https://github.com/lefred/MyUndelete Percona Live Europe Amsterdam 2015
  • 29. Related topic ● MySQL released «Binary Log API» that could be use to decode in a better way the binary logs – http://mysqlhighavailability.com/mysql-binlog-events-reading-and-handling- information-from-your-binary-log/ – http://mysqlhighavailability.com/mysql-binlog-events-use-case-and-examples/ ● Jeremy Cole wrote a Ruby Library to also parse binary logs – https://github.com/jeremycole/mysql_binlog Percona Live Europe Amsterdam 2015
  • 30. Thank you Questions ? Percona Live Europe Amsterdam 2015