2
0

pgxpool waits for connection cleanup to finish before making room in pool

refs #679
This commit is contained in:
Jack Christensen
2020-08-20 22:04:56 -05:00
parent e9579e6249
commit 39b096d01e
4 changed files with 24 additions and 7 deletions
+7 -2
View File
@@ -190,8 +190,13 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
return cr, nil
},
func(value interface{}) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
value.(*connResource).conn.Close(ctx)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
conn := value.(*connResource).conn
conn.Close(ctx)
select {
case <-conn.PgConn().CleanupChan():
case <-ctx.Done():
}
cancel()
},
config.MaxConns,