Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#389: add some logging for error of ConnectionPool.tryConnect #390

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 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,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) {
Expand Down Expand Up @@ -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 {
Expand Down
Loading