Skip to content

Commit dd01599

Browse files
author
Max Maximov
committed
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
1 parent be0f71e commit dd01599

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
99
## [Unreleased]
1010

1111
### Added
12-
12+
- Add err log to `ConnectionPool.Add()` in case, when unable to establish
13+
connection and ctx is not canceled;
14+
also added logs for error case of `ConnectionPool.tryConnect()` calls in
15+
`ConnectionPool.controller()` and `ConnectionPool.reconnect()`
1316
### Changed
1417

1518
### Fixed

pool/connection_pool.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ func (p *ConnectionPool) Add(ctx context.Context, instance Instance) error {
289289
e.cancel()
290290
close(e.closed)
291291
return err
292+
} else {
293+
log.Printf("tarantool: connect to %s failed: %s\n", instance.Name, err)
292294
}
293295
}
294296

@@ -1329,7 +1331,9 @@ func (p *ConnectionPool) reconnect(ctx context.Context, e *endpoint) {
13291331
e.conn = nil
13301332
e.role = UnknownRole
13311333

1332-
p.tryConnect(ctx, e)
1334+
if err := p.tryConnect(ctx, e); err != nil {
1335+
log.Printf("tarantool: reconnect to %s failed: %s\n", e.name, err)
1336+
}
13331337
}
13341338

13351339
func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
@@ -1417,7 +1421,10 @@ func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
14171421
// Relocate connection between subpools
14181422
// if ro/rw was updated.
14191423
if e.conn == nil {
1420-
p.tryConnect(ctx, e)
1424+
if err := p.tryConnect(ctx, e); err != nil {
1425+
log.Printf("tarantool: reopen connection to %s failed: %s\n",
1426+
e.name, err)
1427+
}
14211428
} else if !e.conn.ClosedNow() {
14221429
p.updateConnection(e)
14231430
} else {

0 commit comments

Comments
 (0)