From 692df217ca21b6df8e4dc65538fcc90733e8900e Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Wed, 19 Oct 2016 12:26:55 -0700 Subject: [PATCH] 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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/database/sql/sql.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index defe960742..d363008993 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -814,6 +814,7 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn } // Check if the context is expired. if err := ctx.Err(); err != nil { + db.mu.Unlock() return nil, err } lifetime := db.maxLifetime