Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

data race in conn.go #260

Open
huaz836 opened this issue Jun 21, 2021 · 0 comments
Open

data race in conn.go #260

huaz836 opened this issue Jun 21, 2021 · 0 comments

Comments

@huaz836
Copy link

huaz836 commented Jun 21, 2021

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

Originally posted by @huaz836 in #178 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant