go-mysql-org / go-mysql-elasticsearch

Sync MySQL data into elasticsearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

同步数据失败

logmecn opened this issue · comments

配置和同步都正常,但在同步数据到如下数据时,就会出错而停止同步。怀疑是因为有事务的数据,而同步数据不被支持。
[2020/05/29 14:32:12] [info] master.go:54 save position (mysql-bin.000024, 131978390)
[2020/05/29 14:32:13] [error] sync.go:121 parse query(SAVEPOINT trans2) err line 1 column 9 near "SAVEPOINT trans2"
[2020/05/29 14:32:13] [error] canal.go:230 canal start sync binlog err: line 1 column 9 near "SAVEPOINT trans2"
[2020/05/29 14:32:13] [info] river.go:298 errline 1 column 9 near "SAVEPOINT trans2"

commented

同遇到该问题。全量同步(也就是mysqldump)之后,就是这个错误了。

commented

大概找到原因了:依赖的某个module版本没更新。不过首先说明一下,我对go没什么了解(比如go.mod也只是大致了解了一下),下面的操作可能存在不规范的地方。

在这个issue:go-mysql-org/go-mysql#393
看到说修复了,而且PR也合并了,所以我查看了一下这个工具引用的go-mysql,发现是一个比较旧的版本,反正应该是修复问题前的版本。

https://github.com/siddontang/go-mysql-elasticsearch/blob/d4e881274861e5c33b37cce17abcdac508149c32/go.mod#L12

然后,我把版本修改为latest,然后重新make,接着再运行,OK了。

[2020/08/05 21:45:57] [info] master.go:54 save position (mysql-bin.004946, 55920121)
[2020/08/05 21:46:01] [info] master.go:54 save position (mysql-bin.004946, 55920818)
[2020/08/05 21:46:04] [error] sync.go:145 parse query(SAVEPOINT `LEVEL1`) err line 1 column 9 near "SAVEPOINT `LEVEL1`" , will skip this event
[2020/08/05 21:46:04] [info] master.go:54 save position (mysql-bin.004946, 56073332)
[2020/08/05 21:46:07] [info] master.go:54 save position (mysql-bin.004946, 56187450)
commented

看了一下make之后的go.mod,发现版本号自动由latest更新为v1.1.0了,所以估计修改时这么写也行吧。

module github.com/siddontang/go-mysql-elasticsearch

go 1.12

require (
    github.com/BurntSushi/toml v0.3.1
    github.com/juju/errors v0.0.0-20190207033735-e65537c515d7
    github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
    github.com/prometheus/client_golang v0.9.3
    github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726
    github.com/siddontang/go-log v0.0.0-20190221022429-1e957dd83bed
    github.com/siddontang/go-mysql v1.1.0
)

@ansonhorse could you please file a pr to update the version of go-mysql?