lefred / MyUndelete

Undelete deleted rows from MySQL ROW binary logs
GNU General Public License v2.0
26 stars 13 forks source link

not converting event type when trying undelete #5

Open n0099 opened 10 months ago

n0099 commented 10 months ago

Run

sudo python2 ~/MyUndelete/MyUndelete.py -b binlog.000117 -s 148418658 -e 484776616

only gives me the following error in mysql error log:

[ERROR] [MY-010584] [Repl] Replica SQL: Could not execute Delete_rows event on table db.table; Can't find record in 'table', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's source log FIRST, end_log_pos 148425162, Error_code: MY-001032

but it's able to replace the event type with the original awk script in http://thenoyes.com/littlenoise/?p=307:

BEGIN { regexp = "$^" }

/^BINLOG/ {
  print;
  getline;
  regexp = "^" substr($0, 1, 5) "[CSiy][ABCD]" substr($0, 8, 4);
}

$0 ~ regexp {
  n = $0;
  $0 = substr(n, 1, 5)
  $0 = $0 substr("BRhx", index("CSiy", substr(n, 6, 1)), 1)
  $0 = $0 substr("4567", index("ABCD", substr(n, 7, 1)), 1)
  $0 = $0 substr(n, 8) ;
}

{ print; }
sudo mysqlbinlog --start-position=148418658 --stop-position=484776616 binlog.000117 | awk -f undelete.awk | mysql
n0099 commented 10 months ago

and there's another warn by gawk https://github.com/KittyKatt/screenFetch/issues/627 in the stdout of python2:

awk: cmd. line:1: warning: regexp escape sequence `\;' is not a known regexp operator

can be fix by change this line https://github.com/lefred/MyUndelete/blob/5ccd99c0a5a87ad2ebc8637ebd3a69a20af3e56b/MyUndelete.py#L106 to

- c2 = ['awk', '/\/*!*\/\;/{flag=0}flag;/^BINLOG /{flag=1}'] 
+ c2 = ['awk', '/\/*!*\/;/{flag=0}flag;/^BINLOG /{flag=1}'] 
n0099 commented 10 months ago

I've find out some slideshow made by you about this approach to undelete: https://www.slideshare.net/lefred.descamps/undelete-and-more-rows-from-the-binary-log https://archive.fosdem.org/2018/schedule/event/mysql_pointintime/attachments/slides/2613/export/events/attachments/mysql_pointintime/slides/2613/FOSDEM_MySQL_&_Friends_Devroom,_February_2018___MySQL_Point_In_Time_Recovery_like_a_Rockstar.pdf

lefred commented 10 months ago

Hello this is a very old program that I didn't maintain. I do have in mind something better to handle this, but not much time.