Closed teou closed 5 years ago
I can't reproduce anymore. Close?
$ go version
go version go1.11 linux/amd64
$ git log -n1
commit c4fab1ac1bec58281ad0667dc3f0907a9476ac47
Author: Samuel Stauffer <samuel@descolada.com>
Date: Tue Jan 30 11:37:22 2018 -0800
Fix race conditions in t test
$ go build -race .
$
Reproduce this case when test my app with go race. The log:
2021/06/21 15:21:58 recv loop terminated: err=failed to read from connection: read tcp 192.168.1.101:56952->192.168.1.101:2181: i/o timeout
2021/06/21 15:21:58 recv loop terminated: err=failed to read from connection: read tcp 192.168.1.101:56976->192.168.1.101:2181: i/o timeout
==================
WARNING: DATA RACE
Write at 0x00c0001ee000 by goroutine 77:
github.com/samuel/go-zookeeper/zk.(*Conn).recvLoop()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:910 +0xc4c
github.com/samuel/go-zookeeper/zk.(*Conn).loop.func2()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:521 +0x2f1
Previous read at 0x00c0001ee000 by goroutine 8:
github.com/samuel/go-zookeeper/zk.(*Conn).sendSetWatches()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:637 +0x472
github.com/samuel/go-zookeeper/zk.(*Conn).loop()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:535 +0x5a4
github.com/samuel/go-zookeeper/zk.Connect.func1()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:223 +0x3c
Goroutine 77 (running) created at:
github.com/samuel/go-zookeeper/zk.(*Conn).loop()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:516 +0x576
github.com/samuel/go-zookeeper/zk.Connect.func1()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:223 +0x3c
Goroutine 8 (running) created at:
github.com/samuel/go-zookeeper/zk.Connect()
/gopath/src/github.com/samuel/go-zookeeper/zk/conn.go:222 +0x8c6
// ... more application call stack
// call like this
// zkConn, chanConnect, err := zk.Connect([]string{zkAddr}, time.Second*30, zk.WithLogInfo(false))
==================
centos 7 go 1.16.2 zookeeper 3.6.2
hi guys data race is detected when we run go-zookeeper on : go build -race
WARNING: DATA RACE Write at : github.com/samuel/go-zookeeper/zk.(*Conn).recvLoop() github.com/samuel/go-zookeeper/zk/conn.go:820
Previous read at : github.com/samuel/go-zookeeper/zk.(*Conn).sendSetWatches() github.com/samuel/go-zookeeper/zk/conn.go:567
maybe Conn.lastZxid needs to be lock protected?