Terminate connection when Commit fails and leaves tx open

refs #787
pull/816/head
Jack Christensen 2020-07-13 22:49:35 -05:00
parent c8a9da960c
commit 9b480f4785
1 changed files with 3 additions and 0 deletions

3
tx.go
View File

@ -157,6 +157,9 @@ func (tx *dbTx) Commit(ctx context.Context) error {
commandTag, err := tx.conn.Exec(ctx, "commit")
tx.closed = true
if err != nil {
if tx.conn.PgConn().TxStatus() != 'I' {
_ = tx.conn.Close(ctx) // already have error to return
}
return err
}
if string(commandTag) == "ROLLBACK" {