From edde459335c196d28fc3e0dc8999237835859516 Mon Sep 17 00:00:00 2001 From: Max Maximov Date: Mon, 25 Mar 2024 18:30:13 +0300 Subject: [PATCH] pool: add log messages on connect error Add err log to ConnectionPool.Add() in case, when unable to establish connection and ctx is not canceled; also added logs for error case of ConnectionPool.tryConnect() calls in ConnectionPool.controller() and ConnectionPool.reconnect() Part of #389 --- CHANGELOG.md | 5 ++++- pool/connection_pool.go | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15b4608..a5cc700e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release. ## [Unreleased] ### Added - +- Add err log to `ConnectionPool.Add()` in case, when unable to establish + connection and ctx is not canceled; + also added logs for error case of `ConnectionPool.tryConnect()` calls in + `ConnectionPool.controller()` and `ConnectionPool.reconnect()` ### Changed ### Fixed diff --git a/pool/connection_pool.go b/pool/connection_pool.go index 949b468b..1c9d85f4 100644 --- a/pool/connection_pool.go +++ b/pool/connection_pool.go @@ -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) } } @@ -1329,7 +1331,9 @@ 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) { @@ -1417,7 +1421,10 @@ 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 {