go-zookeeper icon indicating copy to clipboard operation
go-zookeeper copied to clipboard

StateDisconnected

Open xing00lian opened this issue 7 years ago • 1 comments

https://github.com/samuel/go-zookeeper/blob/e6b59f6144beb8570562539c1898a0b1fea34b41/zk/conn.go#L918

type:Unknown, state:StateDisconnected, path:, err:, server: when kill my process, I always get this message

func (electionManager *ElectionManager) watchMaster() { children, state, childCh, err := electionManager.ZKClientConn.ChildrenW(electionManager.ZKConfig.RootPath + electionManager.ZKConfig.MasterPath) if err != nil { fmt.Println("watch children error, ", err) }

    for {
            select {
            case childEvent := <-childCh:
                    fmt.Printf("type:%v, state:%v, path:%v, err:%v, server:%v\n", childEvent.Type, childEvent.State, childEvent.Path, childEvent.Err, childEvent.Server)
                    if childEvent.Type == zk.EventNodeDeleted {
                            // 重新选举
                            if err = electionManager.electMaster(); err != nil {
                                    fmt.Println("elect new master error, ", err)
                            }
                    }
            }
    }

}

xing00lian avatar Aug 17 '17 06:08 xing00lian

I got the same result when kill my FlagEphemeral znode connect. How to deal with this?

TrueAbc avatar Jul 21 '20 01:07 TrueAbc