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

Fix continuous loop of connect attempts #38

Merged
merged 1 commit into from
Apr 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix continuous loop of connect attempts
Sometimes zookeeper just drops connection on invalid session data,
we prefer to drop session and start from scratch when that event
occurs instead of dropping into loop of connect/disconnect attempts.

This can be emulated by stopping zookeeper, cleaning it's database and
starting it again. But we experience same bug in production without
cleaning zookeeper, but in case of network partition (not every partition
event).
  • Loading branch information
tailhook committed Nov 13, 2014
commit 969553d3c8a7022b367cd74cd193bf7b90d6864d
9 changes: 8 additions & 1 deletion zk/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,14 @@ func (c *Conn) authenticate() error {
// package length
_, err = io.ReadFull(c.conn, buf[:4])
if err != nil {
return err
// Sometimes zookeeper just drops connection on invalid session data,
// we prefer to drop session and start from scratch when that event
// occurs instead of dropping into loop of connect/disconnect attempts
c.sessionID = 0
c.passwd = emptyPassword
c.lastZxid = 0
c.setState(StateExpired)
return ErrSessionExpired
}

blen := int(binary.BigEndian.Uint32(buf[:4]))
Expand Down