Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stdlib/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ func (c *Conn) ResetSession(ctx context.Context) error {
return driver.ErrBadConn
}

// Discard connection if it has an open transaction. This can happen if the
// application did not properly commit or rollback a transaction.
if c.conn.PgConn().TxStatus() != 'I' {
return driver.ErrBadConn
}

now := time.Now()
idle := now.Sub(c.lastResetSessionTime)

Expand Down