Skip to content

Commit

Permalink
improve control connection error/reconnection logging
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-r-reis committed May 29, 2024
1 parent 5ad3248 commit 5aba4d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 9 additions & 0 deletions control.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ func (c *controlConn) setupConn(conn *Conn) error {
}

c.conn.Store(ch)

c.session.logger.Info("gocql: control connection connected to %v (%s).",
NewLogField("host_addr", host.ConnectAddress().String()), NewLogField("host_id", host.HostID()))

if c.session.initialized() {
// We connected to control conn, so add the connect the host in pool as well.
// Notify session we can start trying to connect to the node.
Expand Down Expand Up @@ -463,6 +467,11 @@ func (c *controlConn) HandleError(conn *Conn, err error, closed bool) {
return
}

c.session.logger.Info("gocql: control connection error %v (%s): %v\n",
NewLogField("host_addr", conn.host.ConnectAddress().String()),
NewLogField("host_id", conn.host.HostID()),
NewLogField("err", err.Error()))

c.reconnect()
}

Expand Down
13 changes: 0 additions & 13 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,6 @@ func (s *Session) init() error {
return err
}

controlHostConn := s.control.getConn()
var controlHost *HostInfo
var controlHostAddr string
var controlHostId string
if controlHostConn != nil {
controlHost = controlHostConn.host
controlHostAddr = controlHost.ConnectAddress().String()
controlHostId = controlHost.HostID()
}

s.logger.Info("gocql: control connection successfully connected to host %v (%v).",
NewLogField("host_addr", controlHostAddr), NewLogField("host_id", controlHostId))

if !s.cfg.DisableInitialHostLookup {
var partitioner string
newHosts, partitioner, err := s.hostSource.GetHosts()
Expand Down

0 comments on commit 5aba4d2

Please sign in to comment.