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

Cisco stack wise technology
Cisco stack wise technologyCisco stack wise technology
Cisco stack wise technologyiTawy Community
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧
現代 IT 人一定要知道的 Ansible 自動化組態技巧現代 IT 人一定要知道的 Ansible 自動化組態技巧
現代 IT 人一定要知道的 Ansible 自動化組態技巧Chu-Siang Lai
 
Demystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesDemystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesCumulus Networks
 
06 evpn use-case_reviewv1
06 evpn use-case_reviewv106 evpn use-case_reviewv1
06 evpn use-case_reviewv1ronsito
 
OpenDaylight app development tutorial
OpenDaylight app development tutorialOpenDaylight app development tutorial
OpenDaylight app development tutorialSDN Hub
 
NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home ADVA
 
Openwrt wireless
Openwrt wirelessOpenwrt wireless
Openwrt wireless晓东 杜
 
MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2GLC Networks
 
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dell
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dellCompetitive switching comparison cisco vs. hpe aruba vs. huawei vs. dell
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dellIT Tech
 
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)Kentaro Ebisawa
 
Junos routing overview from Juniper
Junos routing overview from JuniperJunos routing overview from Juniper
Junos routing overview from JuniperNam Nguyen
 
Troubleshooting for Intent-based Networking
Troubleshooting for Intent-based NetworkingTroubleshooting for Intent-based Networking
Troubleshooting for Intent-based NetworkingOpen Networking Summit
 
Module 1: ConfD Technical Introduction
Module 1: ConfD Technical IntroductionModule 1: ConfD Technical Introduction
Module 1: ConfD Technical IntroductionTail-f Systems
 
Build enterprise wireless with CAPsMAN
Build enterprise wireless with CAPsMANBuild enterprise wireless with CAPsMAN
Build enterprise wireless with CAPsMANGLC Networks
 

What's hot (20)

Cisco stack wise technology
Cisco stack wise technologyCisco stack wise technology
Cisco stack wise technology
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧
現代 IT 人一定要知道的 Ansible 自動化組態技巧現代 IT 人一定要知道的 Ansible 自動化組態技巧
現代 IT 人一定要知道的 Ansible 自動化組態技巧
 
Demystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesDemystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode series
 
NETCONF YANG tutorial
NETCONF YANG tutorialNETCONF YANG tutorial
NETCONF YANG tutorial
 
06 evpn use-case_reviewv1
06 evpn use-case_reviewv106 evpn use-case_reviewv1
06 evpn use-case_reviewv1
 
Brkdct 3101
Brkdct 3101Brkdct 3101
Brkdct 3101
 
OpenDaylight app development tutorial
OpenDaylight app development tutorialOpenDaylight app development tutorial
OpenDaylight app development tutorial
 
NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home
 
Openwrt wireless
Openwrt wirelessOpenwrt wireless
Openwrt wireless
 
MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2
 
Arc flash example4
Arc flash example4Arc flash example4
Arc flash example4
 
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dell
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dellCompetitive switching comparison cisco vs. hpe aruba vs. huawei vs. dell
Competitive switching comparison cisco vs. hpe aruba vs. huawei vs. dell
 
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
 
Junos routing overview from Juniper
Junos routing overview from JuniperJunos routing overview from Juniper
Junos routing overview from Juniper
 
Gate driver design and inductance fabrication
Gate driver design and inductance fabricationGate driver design and inductance fabrication
Gate driver design and inductance fabrication
 
Troubleshooting for Intent-based Networking
Troubleshooting for Intent-based NetworkingTroubleshooting for Intent-based Networking
Troubleshooting for Intent-based Networking
 
Module 1: ConfD Technical Introduction
Module 1: ConfD Technical IntroductionModule 1: ConfD Technical Introduction
Module 1: ConfD Technical Introduction
 
Build enterprise wireless with CAPsMAN
Build enterprise wireless with CAPsMANBuild enterprise wireless with CAPsMAN
Build enterprise wireless with CAPsMAN
 
Ccna new syllabus
Ccna new syllabusCcna new syllabus
Ccna new syllabus
 
EIN overview
EIN overviewEIN overview
EIN overview
 

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
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 MinutesSveta Smirnova
 
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 MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLRonald Bradford
 
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
 
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
 

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
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
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 MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQL
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQL
 
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
 

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

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

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