Skip to content

Commit

Permalink
tarantool#389: add some logging for error of ConnectionPool.tryConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Maximov committed Mar 25, 2024
1 parent be0f71e commit 865fc53
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pool/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ func (p *ConnectionPool) Add(ctx context.Context, instance Instance) error {
e.cancel()
close(e.closed)
return err
} else {
log.Printf("tarantool: connect to %s failed: %s\n", instance.Name, err)
}
}

Expand Down Expand Up @@ -1329,14 +1331,20 @@ func (p *ConnectionPool) reconnect(ctx context.Context, e *endpoint) {
e.conn = nil
e.role = UnknownRole

p.tryConnect(ctx, e)
if err := p.tryConnect(ctx, e); err != nil {
log.Printf("tarantool: reconnect to %s failed: %s\n", e.name, err)
}
}

func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
timer := time.NewTicker(p.opts.CheckTimeout)
defer timer.Stop()

shutdown := false
var (
shutdown = false
err error
)

for {
if shutdown {
// Graceful shutdown in progress. We need to wait for a finish or
Expand Down Expand Up @@ -1417,7 +1425,9 @@ func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
// Relocate connection between subpools
// if ro/rw was updated.
if e.conn == nil {
p.tryConnect(ctx, e)
if err = p.tryConnect(ctx, e); err != nil {
log.Printf("tarantool: reopen connection to %s failed: %s\n", e.name, err)
}
} else if !e.conn.ClosedNow() {
p.updateConnection(e)
} else {
Expand Down

0 comments on commit 865fc53

Please sign in to comment.