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

data race in conn.go #260

@huaz836

Description

@huaz836

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions