Code Monkey home page Code Monkey logo

canal-go's Issues

release版本

为何没有release?使用的时候无法锁定版本

客户端报错 something goes wrong with reason:something goes wrong with channel

错误信息

panic: something goes wrong with reason:something goes wrong with channel:[id: 0x7f903ed0, /172.25.56.90:52211 => /10.179.25.89:11111], exception=com.alibaba.otter.canal.server.exception.CanalServerException: ClientIdentity:ClientIdentity[destination=example,clientId=1001,filter=<null>] should subscribe first


goroutine 1 [running]:
github.com/CanalClient/canal-go/client.(*SimpleCanalConnector).receiveMessages(0xc0000f3f00, 0x2e)
	/Users/test/go/src/github.com/CanalClient/canal-go/client/SimpleCanalConnector.go:272 +0x838
github.com/CanalClient/canal-go/client.(*SimpleCanalConnector).GetWithOutAck(0xc0000f3f00, 0x3e8, 0x0, 0xc0000f3e14, 0x0)
	/Users/test/go/src/github.com/CanalClient/canal-go/client/SimpleCanalConnector.go:191 +0x2ec
github.com/CanalClient/canal-go/client.(*SimpleCanalConnector).Get(0xc0000f3f00, 0x3e8, 0x0, 0x0, 0x0)
	/Users/test/go/src/github.com/CanalClient/canal-go/client/SimpleCanalConnector.go:196 +0x47
main.main()
	/Users/test/go/src/server_cache/public/canal_client.go:21 +0x13a

Process finished with exit code 2

代码

func main()  {
	connector := client.NewSimpleCanalConnector("mc1.cn", 11111, "", "", "example", 60000, 60*60*1000)
	connector.Connect()

	fmt.Println("连接成功")
	for {
		message := connector.Get(1000, nil, nil)
		batchId := message.Id
		if batchId == -1 || len(message.Entries) <= 0 {
			time.Sleep(300 * time.Millisecond)
			fmt.Println("===没有数据了===")
			continue
		}

		printEntry(message.Entries)
	}
}

使用java客户端测试可以正常的获取binlog日志解析,环境是 centeros6.7+mysql5.7+go1.11

客户端不支持canal 1.1.2

对canal 1.1.0 解析正常,升级canal 1.1.2 后,获取不到数据,无报错
是哪里需要修改一下么?

客户端解码问题

cancal用的是canal/canal-server: v1.1.0镜像,客户端一直没有成功
遇到两个问题
第一个:在get的时候解码报错了,偶现
Fatal error: proto: Messages: illegal tag 0 (wire type 0)exit status 1

第二个:如果get成功了,就一定会报这个错误
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5222d2]

goroutine 1 [running]:
github.com/CanalClient/canal-go/protocol.(*RowChange).Reset(0x0)
/home/wenyuanhao/goworkspace/src/github.com/CanalClient/canal-go/protocol/EntryProtocol.pb.go:917 +0x22
github.com/CanalSharp/canal-go/vendor/github.com/golang/protobuf/proto.Unmarshal(0xc420016240, 0x17, 0x20, 0x6481c0, 0x0, 0x0, 0x68)
/home/wenyuanhao/goworkspace/src/github.com/CanalSharp/canal-go/vendor/github.com/golang/protobuf/proto/decode.go:336 +0x3b
main.printEntry(0xc42017c000, 0x1b0, 0x266)
/home/wenyuanhao/goworkspace/src/github.com/CanalSharp/canal-go/samples/main.go:41 +0x149
main.main()
/home/wenyuanhao/goworkspace/src/github.com/CanalSharp/canal-go/samples/main.go:29 +0x1d9
exit status 2

消费数据中断

我按照Demo连接了测试的canal ,但发现数据成功消费了一部分后,就不再消费这是怎么回事(实际是有数据更新的)
image

ClusterCanalConnector 多个实例监听多个 Destination 只有一个能竞争到

你好,我们在用 canal-go 来消费多个 Destination 的 binlog 做数据同步,但是发现多个实例只有一个能够竞争到并且连接到 canal-server。

看代码实现 doConnect 的时候,zk 的 path 都是 /canal-consumer,如果启动了多个实例,要去监听不同的 Destination,看起来只有一个实例能够竞争到去 Connect。

修改了一下用 "/canal-consumer/" + destination 拼接成 zk 的 path 就可以了。不知道这里这样实现会不会有坑。

const 	(
	runningFlag = byte(0)
	notRunningFlag = byte(0)
	path = "/canal-consumer"
)

func NewClusterCanalConnector(canalNode *CanalClusterNode, username string, password string, destination string,
	soTimeOut int32, idleTimeOut int32) (*ClusterCanalConnector,error) {

	destinationPath := fmt.Sprintf("%s/%s", path, destination)

	err := checkRootPath(canalNode.zkClient, destinationPath)
	if err != nil {
		return nil, err
	}

	currentSequence, err := createEphemeralSequence(canalNode.zkClient, destinationPath)
	if err != nil {
		return nil,err
	}

	cluster := &ClusterCanalConnector{
		canalNode:   canalNode,
		username:    username,
		password:    password,
		destination: destination,
		soTimeOut:   soTimeOut,
		idleTimeOut: idleTimeOut,
		RetryTimes:  0,
		currentSequence:currentSequence,
		zkVersion:	 0,
		Path:		 destinationPath,
	}

	return cluster, nil
}

批量丢失数据

你好,这边在使用canal-go客户端的时候。发现在触发批量更新的是,客户端不能接收到所有的数据,debug发现,在p.body中数据是全的,但是通过proto.Unmarshal(p.Body, messages) 解析后,到messages就不正确了。
image

mysql协议解析问题

代码位置:/client/simple_canal_connector.go

func readNextPacket() ([]byte, error) {
.....
        rdr := bufio.NewReader(conn)
	data := make([]byte, 0, 4*1024)
	n, err := io.ReadFull(rdr, data[:4])
	if err != nil {
		return nil, err
	}
	data = data[:n]
	dataLen := binary.BigEndian.Uint32(data)
	if uint64(dataLen) > uint64(cap(data)) {
		data = make([]byte, 0, dataLen)
	}
	n, err = io.ReadFull(rdr, data[:dataLen])
	if err != nil {
		return nil, err
	}
	data = data[:n]
	return data, nil
}

mysql的协议格式中,前四个字节位 |data_len| sequence_id |
但是代码里的处理是直接把前四个字节当作数据的长度,是有问题吧?还是我理解错了?

unsupported version at this client

pb版本冲突之后, 更新v1.1.1的包之后, 出现这种问题, 是不是 docker的image cannal-server 也要配套的 v.1.1.1 版本?

获取不到详细的内容

获取不到具体的内容,在sample中直接打印fmt.Println(message.Entries),获取到的信息是
[{version:1 logfileName:"mysql-bin.000002" logfileOffset:23611 serverId:1 serverenCode:"UTF-8" executeTime:1541055476000 sourceType:MYSQL eventLength:72 0xc42001243c [32 189 45] {} [] 0} {version:1 logfileName:"mysql-bin.000002" logfileOffset:24257 serverId:1 serverenCode:"UTF-8" executeTime:1541055476000 sourceType:MYSQL eventLength:27 0xc42001246c [18 6 51 57 52 56 55 51] {} [] 0}]

相同的canal instance,用java能获取到内容( 客户端用的是https://github.com/liukelin/canal_mysql_nosql_sync/tree/master/canal-client ),在java连接成功后会有一个log
2018-11-01 15:06:39.566 [New I/O server worker #1-2] INFO c.a.otter.canal.instance.core.AbstractCanalInstance - subscribe filter change to ...

此时再断开java客户端,运行go客户端,就可以获取到信息,但是重启canal instance后又不行

无法监听canal数据

最新版本1.09无法监听到非cluster下canal的数据,simples下的main.go运行后没有数据。。。
canal-deployer 版本是1.1.4, MySQL是阿里云RDS,5.6

有中文乱码问题

canal-go链接canal后接收到message,进行解析,出现中文乱码。
请问如何解决?

多个canal-go连接同一个canal server后挂掉

使用的是 client.NewSimpleCanalConnector(),是否只能起一个客户端?
起多个相同的客户端后,全部客户段都挂了。
Panicing something goes wrong with reason:something goes wrong with channel:[id: 0x5609bb8b, /127.0.0.1:49897 =\u003e /127.0.0.1:11111], exception=com.alibaba.otter.canal.server.exception.CanalServerException: ack error , clientId:1001 batchId:18 is not exist , please check

Panicing something goes wrong with reason:something goes wrong with channel:[id: 0x6e1eb5f4, /127.0.0.1:50066 =\u003e /127.0.0.1:11111], exception=com.alibaba.otter.canal.meta.exception.CanalMetaManagerException: batchId:21 is not the firstly:20

我的逻辑是先获取了数据,处理后再应答,但多个客户端的情况下不按顺序应答会有问题,请问如何解决?

无法获取详细变更内容

情况描述

在完成了简单配置后,运行sample中的main函数,无法获取到update、delete等操作等变化记录,只能得到如下信息
&{3 [{version:1 logfileName:"mysql-bin.000056" logfileOffset:73667 serverId:1682989439 serverenCode:"UTF-8" executeTime:1573480770000 sourceType:MYSQL eventLength:68 0xc000018830 [32 144 79] {} [] 0} {version:1 logfileName:"mysql-bin.000056" logfileOffset:73837 serverId:1682989439 serverenCode:"UTF-8" executeTime:1573480770000 sourceType:MYSQL eventLength:31 0xc000018860 [18 5 52 53 49 56 55] {} [] 0}] false }
TRANSACTIONBEGIN
TRANSACTIONEND

##配置文件如下

  • conf/example/example.conf, 只做了如下修改:
canal.instance.master.address=xx.xx.xx.xx:3306
  • conf/canal.properties, 只做了如下修改:
canal.instance.parser.parallel = false

canal 1.1.5 连接启动失败

panic: runtime error: slice bounds out of range [:10004] with capacity 240 [recovered]
panic: runtime error: slice bounds out of range [:10004] with capacity 240

goroutine 19 [running]:
github.com/samuel/go-zookeeper/zk.decodePacket.func1(0xc00022de68)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/structs.go:398 +0xfe
panic(0xc65aa0, 0xc000416000)
C:/Program Files/Go/src/runtime/panic.go:969 +0x1c7
github.com/samuel/go-zookeeper/zk.decodePacketValue(0xc000400010, 0x0, 0xf0, 0xc13760, 0xc00040a010, 0x197, 0x197, 0x0, 0x0)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/structs.go:474 +0xa4a
github.com/samuel/go-zookeeper/zk.decodePacketValue(0xc000400000, 0x10, 0x100, 0xc08e60, 0xc00040a000, 0x16, 0x10, 0x100, 0xc00022de28)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/structs.go:433 +0x471
github.com/samuel/go-zookeeper/zk.decodePacket(0xc000400000, 0x10, 0x100, 0xc08e60, 0xc00040a000, 0x0, 0x0, 0x0)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/structs.go:407 +0x178
github.com/samuel/go-zookeeper/zk.(*Conn).authenticate(0xc000224420, 0x0, 0x0)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/conn.go:726 +0x45b
github.com/samuel/go-zookeeper/zk.(*Conn).loop(0xc000224420)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/conn.go:486 +0x65
github.com/samuel/go-zookeeper/zk.Connect.func1(0xc000224420)
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/conn.go:223 +0x36
created by github.com/samuel/go-zookeeper/zk.Connect
D:/GoPath/pkg/mod/github.com/samuel/[email protected]/zk/conn.go:222 +0x4b8

配置访问账号和密码后,总是返回EOF错误

在canal-server中配置了如下的访问控制方式

# canal instance user/passwd
canal.user = canal
canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458

使用canal-go的代码

connector := client.NewSimpleCanalConnector("192.168.199.17", 11111, "canal", "canal", "example", 60000, 60*60*1000)
err:=connector.Connect()

err总是为EOF错误

但在使用Java客户端时,能正常连接 https://github.com/alibaba/canal/tree/master/example

不知是不是BUG

场景:
1)所有组件均正常运行中。。
2)canal-go开始读取数据,读了一会,提示没有数据,然后很长一段时间,比如1分钟,仍然提示没有数据,但是当使用CTRL+C终止客户端后,再重运行,突然会有一堆数据出来。

3)此情况,应该可以重现,不知是否BUG?

文件名多了一个点

原文件 /protocol/Position/log_identity..go,导致 go get 报错。应该是 /protocol/Position/log_identity.go。

Decode RawEntries模式时,raw没有赋值为true

根据java的客户端代码来理解lazyParseEntry 模式时需要设置raw为true。
java代码

                      if (lazyParseEntry) {
                            // byteString
                            result.setRawEntries(messages.getMessagesList());
                            result.setRaw(true);
                        }

参考:https://github.com/alibaba/canal/blob/master/client/src/main/java/com/alibaba/otter/canal/client/CanalMessageDeserializer.java#L35
目前canal-go代码

                if lazyParseEntry {
			message.RawEntries = messages.Messages
		}

https://github.com/withlin/canal-go/blob/master/protocol/Message.go#L62

canal-go 不支持1.1.4版本的Canal server!!!

我下載了最新版的Canal server, 版本号是1.1.4, 然后用php版的canal client连接做测试, 都能正常使用, 后来准备用Go版本的canal client, 一连接, 发现怎么改数据库, 都是提示:===没有数据了===, 这我就郁闷了, 再详细看你们的文档, 是用docker环境来run mysql和canal server. 我就尝试下, 发现docker环境用的canal server居然是1.1.0版本的, 然后发现居然能用了。。。go版本的client什么时候能支持 1.1.4 版本的 canal server???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.