pgx.Connect は thread safe ではない
failed to deallocate cached statement(s): conn busy
pgx/v5 で上記みたいなエラーが出まくったばあいは、pgx.Connect()
を間違って使ってるかもしれない。
pgxpool.New()
を使いましょう。
The *pgx.Conn returned by pgx.Connect() represents a single connection and is not concurrency safe. This is entirely appropriate for a simple command line example such as above. However, for many uses, such as a web application server, concurrency is required. To use a connection pool replace the import github.com/jackc/pgx/v5 with github.com/jackc/pgx/v5/pgxpool and connect with pgxpool.New() instead of pgx.Connect().
https://github.com/jackc/pgx/wiki/Getting-started-with-pgx#using-a-connection-pool
Published: 2025-06-26(Thu) 17:45