samuel / go-zookeeper

Native ZooKeeper client for Go. This project is no longer maintained. Please use https://github.com/go-zookeeper/zk instead.
BSD 3-Clause "New" or "Revised" License
1.64k stars 672 forks source link

Close is waiting indefinitely #211

Open pvallem opened 5 years ago

pvallem commented 5 years ago

When Close is invoked, zk_client waits indefinitely on this line. Buffered channel(c.sendChan) is full and waiting to send a request over this channel.

(dlv) bt
0  0x000000000042ebac in runtime.gopark
   at golang/go-1.9.2/src/runtime/proc.go:288
1  0x000000000042ec9e in runtime.goparkunlock
   at golang/go-1.9.2/src/runtime/proc.go:293
2  0x000000000040568b in runtime.chansend
   at golang/go-1.9.2/src/runtime/chan.go:222
3  0x0000000000405413 in runtime.chansend1
   at golang/go-1.9.2/src/runtime/chan.go:113
4  0x000000000079dbaf in vendor/github.com/samuel/go-zookeeper/zk.(*Conn).Close
   at /<Internal Path>/vendor/github.com/samuel/go-zookeeper/zk/conn.go:945

Though this method

c.queueRequest(opClose, &closeRequest{}, &closeResponse{}, nil)

is in select call, for select to work it has to collect the channel before waiting on channel. In this case channel is never read and Close call is waiting indefinitely. Do we know why this might be happening? If it just a matter of honoring the timeout, can we please ensure, Close honors the timeout in https://github.com/samuel/go-zookeeper/blob/master/zk/conn.go#L317 ?

deckarep commented 4 years ago

Also seem to be affected by this.