Skip to content

pop.Connection.Transaction can leak connections #748

@chrisseto

Description

@chrisseto

Description

If a user's code panics within a pop.Connection.Transaction closure, .Rollback nor .Commit will not be called resulting in a leaked SQL connection.

Steps to Reproduce the Problem

func DoThing(conn *pop.Connection) {
    _ = conn.Transaction(func(tx *pop.Connection) error {
        panic("Oh no, this is probably due to a null pointer exception!")
    })
}

Expected Behavior

.Transaction should recover panics and attempt to call .Rollback before re-panicking the error.

Actual Behavior

A SQL connection is silently leaked. Depending on your connection pool setting, you might not even notice.

Info

This issue is not specific to an OS and is observable on the latest main commit (4e72fd8) as of writing

Metadata

Metadata

Assignees

Labels

bugSomething isn't workings: fixedwas fixed or solution offered

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions