Skip to content

Commit bc9aa2d

Browse files
authored
PostgreSQL: avoid usage of cancelled context when deallocating prepared statements (#325)
1 parent 2154d9b commit bc9aa2d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/server/datasource/rdbms/postgresql/connection_manager.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package postgresql
33
import (
44
"context"
55
"fmt"
6+
"time"
67

78
"github.com/jackc/pgx/v5"
89
"github.com/jackc/pgx/v5/pgconn"
@@ -146,7 +147,10 @@ func (c *connectionManager) Make(
146147
return []rdbms_utils.Connection{&connection{conn, queryLogger, dsi, params.TableName}}, nil
147148
}
148149

149-
func (*connectionManager) Release(ctx context.Context, logger *zap.Logger, cs []rdbms_utils.Connection) {
150+
func (*connectionManager) Release(_ context.Context, logger *zap.Logger, cs []rdbms_utils.Connection) {
151+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
152+
defer cancel()
153+
150154
for _, conn := range cs {
151155
if err := conn.(*connection).Conn.DeallocateAll(ctx); err != nil {
152156
logger.Error("deallocate prepared statements", zap.Error(err))

0 commit comments

Comments
 (0)