Skip to content

Commit

Permalink
bugfix: do not recreate a connection immediately
Browse files Browse the repository at this point in the history
If we create a connection immediately after closing previous, then it
can to lead to too frequent connection creation under some
configurations [1] and high CPU load. It will be expected to recreate
connection with OptsPool.CheckTimeout frequency.

1. #136

Part of #208
  • Loading branch information
oleg-jukovec committed Aug 18, 2022
1 parent 4709c8c commit 22af2df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- ConnectionPool does not close UnknownRole connections (#208)
- Segmentation faults in ConnectionPool requests after disconnect (#208)
- Addresses in ConnectionPool may be changed from an external code (#208)
- ConnectionPool recreates connections too often (#208)

## [1.8.0] - 2022-08-17

Expand Down
15 changes: 1 addition & 14 deletions connection_pool/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,20 +702,7 @@ func (connPool *ConnectionPool) checker() {
return
}
if e.Conn.ClosedNow() {
addr := e.Conn.Addr()
if conn, _ := connPool.getConnectionFromPool(addr); conn == nil {
continue
}
conn, _ := tarantool.Connect(addr, connPool.connOpts)
if conn != nil {
err := connPool.setConnectionToPool(addr, conn)
if err != nil {
conn.Close()
log.Printf("tarantool: storing connection to %s failed: %s\n", addr, err.Error())
}
} else {
connPool.deleteConnectionFromPool(addr)
}
connPool.deleteConnectionFromPool(e.Conn.Addr())
}
case <-timer.C:
for _, addr := range connPool.addrs {
Expand Down

0 comments on commit 22af2df

Please sign in to comment.