godannylai / binlog_rollback Goto Github PK
View Code? Open in Web Editor NEWmysql binlog rollback | flashback | redo | dml report | ddl info mysql binlog 回滚/闪回, 前滚, DML分析报告, DDL信息
mysql binlog rollback | flashback | redo | dml report | ddl info mysql binlog 回滚/闪回, 前滚, DML分析报告, DDL信息
我下载的2.1release二进制包,linux下测试,发现生成的rollback的update语句更新的字段不是之前更新的那个字段,往后错位了一个字段。
mysql版本:5.7.24
操作系统:centos7.5
/opt/binlog/binlog_rollback
-m repl -w 2sql
-sbin mysql-bin.000088 -spos 154
-ebin mysql-bin.000099 -epos 154
-H 127.0.0.1 -u username -p ******
-e -o /opt/binlog
执行时报错:
time="2019-03-07_15:26:11" level=error errcode=2
Fail to generate update sql for zentao.zt_searchdict mysql-bin.000088 1992987-1993098
error: No column updated. Generated sql: UPDATE zentao
.zt_searchdict
ORIGINAL STACK TRACE:
github.com/dropbox/godropbox/database/sqlbuilder.(*updateStatementImpl).String
E:/danny/src/go/src/github.com/dropbox/godropbox/database/sqlbuilder/statement.go:721 +0x6a5981
main.GenUpdateSqlsForOneRowsEvent
E:/danny/src/go/src/binlog_rollback/sqlgen.go:437 +0x6c038b
main.GenForwardRollbackSqlFromBinEvent
E:/danny/src/go/src/binlog_rollback/process_events.go:367 +0x6b9f27
runtime.goexit
D:/dannyinstall/go/src/runtime/asm_amd64.s:1333 +0x456481
rows data:[-28691 迭]
[-28691 迭]
该段binlog内容如下:
mysqlbinlog -vv --base64-output=DECODE-ROWS --start-position=1992987 --stop-position=1993098 mysql-bin.000088
/!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1/;
/!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0/;
DELIMITER /!/;
#190226 9:05:45 server id 101 end_log_pos 1993048 CRC32 0x49b86b7e Table_map: zentao
.zt_searchdict
mapped to number 2023
#190226 9:05:45 server id 101 end_log_pos 1993098 CRC32 0x590d8ae5 Update_rows: table id 2023 flags: STMT_END_F
zentao
.zt_searchdict
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog / /!*/;
DELIMITER ;
/!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE/;
/!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0/;
出错部分的数据库信息:
mysql> desc zt_searchdict;
+-------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------------------+------+-----+---------+-------+
| key | smallint(5) unsigned | NO | PRI | NULL | |
| value | char(3) | NO | | NULL | |
+-------+----------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> select * from zt_searchdict where value="迭";
+-------+-------+
| key | value |
+-------+-------+
| 36845 | 迭 |
+-------+-------+
1 row in set (0.00 sec)
[root@masterdb-erp binlog_rollback]# go build
../../../src/github.com/pingcap/tidb/types/errors.go:98:48: undefined: mysql.ErrInvalidFieldSize
您好:
binlog解析结果中建议增加DML语句对应的线程ID,以便审计
[root@szwtlother1040 ~]# ./binlog_rollback -m file -w stats -M mysql -i 20 -b 100 -l 10 -o . mysql-bin.007917
time="2020-03-25_22:21:43" level=info errcode=0 errmsg="start to parse binlog from local files"
time="2020-03-25_22:21:43" level=info errcode=0
start to parse mysql-bin.007917 4
time="2020-03-25_22:21:43" level=info errcode=0 errmsg="start thread to analyze statistics from binlog"
time="2020-03-25_22:21:43" level=error errcode=2 errmsg="error to parse sql: DROP PROCEDURE IF EXISTS xxxxx
: line 1 column 14 near "DROP PROCEDURE IF EXISTS xxxxxxx
" (total length 50)"
error to parse sql from query event, binlog=(mysql-bin.007917, 23046502), time=2020-03-23_16:34:23, sql=DROP PROCEDURE IF EXISTS xxxxxx
[root@masterdb-erp binlog_flashback]# ./binlog_rollback -m file -w stats -M mysql -i 20 -b 100 -l 10 -sbin="mysql-bin.000067" -spos=11181440 -o /root/binlog_flashback/binlogs_dir /server/mysql_data/mysql38375/data/mysql-bin.000067
time="2019-11-12_20:00:36" level=info errcode=0 errmsg="start to parse binlog from local files"
time="2019-11-12_20:00:36" level=info errcode=0
start to parse /server/mysql_data/mysql38375/data/mysql-bin.000067 11181440
time="2019-11-12_20:00:36" level=info errcode=0 errmsg="start thread to analyze statistics from binlog"
panic: assignment to entry in nil map
goroutine 18 [running]:
main.ProcessBinEventStats(0xc0000840d0, 0xc0000840d8, 0xc0000840e0, 0x10cc080, 0xc000086ae0, 0xc0001e61d0)
E:/danny/src/go_person/src/binlog_rollback/stats_process.go:247 +0xa70
created by main.main
E:/danny/src/go_person/src/binlog_rollback/main.go:32 +0x487
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.