Skip to content

Commit 692df21

Browse files
kardianosbradfitz
authored andcommitted
database/sql: add missing unlock when context is expired
Missing the DB mutex unlock on an early return after checking if the context has expired. Fixes #17518 Change-Id: I247cafcef62623d813f534a941f3d5a3744f0738 Reviewed-on: https://go-review.googlesource.com/31494 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 9cefbe9 commit 692df21

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/database/sql/sql.go

+1
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn
814814
}
815815
// Check if the context is expired.
816816
if err := ctx.Err(); err != nil {
817+
db.mu.Unlock()
817818
return nil, err
818819
}
819820
lifetime := db.maxLifetime

0 commit comments

Comments
 (0)