pgx
pgx copied to clipboard
Is pgxpool.Tx.{Commit,Rollback} check for tx.c redundant?
pgxpool.Tx.{Commit,Rollback} contain the following snippet (https://github.com/jackc/pgx/blob/v5.7.6/pgxpool/tx.go#L25):
if tx.c != nil {
tx.c.Release()
tx.c = nil
}
However the documentation for pgxpool.Conn.Release says
"However, it is safe to call Release multiple times. Subsequent calls after the first will be ignored."
and the implementation exits quickly if the Release was called already (https://github.com/jackc/pgx/blob/v5.7.6/pgxpool/conn.go#L20):
if c.res == nil {
return
}
conn := c.Conn()
res := c.res
c.res = nil
So is the checking in Tx redundant?
It's not redundant. I just tried removing it and the tests hang.