diff options
| author | Damien Neil <dneil@google.com> | 2026-03-14 19:54:47 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-25 13:28:25 -0700 |
| commit | cdfc8c771301c8c1f32e50e773d620a6b8767078 (patch) | |
| tree | 8433bbcd73288cd1952be1363c92f0985f79d8fe /src/database/sql/sql_test.go | |
| parent | 670038a5a53c19ab299179e62d72956a92248877 (diff) | |
| download | go-cdfc8c771301c8c1f32e50e773d620a6b8767078.tar.xz | |
database/sql: avoid deadlock from reentrant RLock
RWMutex.RLock blocks until any pending Lock operations are satisfied.
This prohibits recursive read-locking. Replace various RWMutexes
used to synchronize between reads and closes with a variant where
the reader side takes priority. Reads can starve out Close, but will
not deadlock.
Fixes #78304
Change-Id: Id36529bf86bed5dbf22f2af94283aeac6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/758064
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Neal Patel <nealpatel@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/database/sql/sql_test.go')
| -rw-r--r-- | src/database/sql/sql_test.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go index 5f093a2d6d..40da17472d 100644 --- a/src/database/sql/sql_test.go +++ b/src/database/sql/sql_test.go @@ -4483,6 +4483,8 @@ func testContextCancelDuringRawBytesScan(t *testing.T, mode string) { for _, b := range s { // some operation reading from the raw memory sink += b } + // r.Columns must not deadlock acquiring closemu.RLock. + _, _ = r.Columns() } if r.closemuScanHold { t.Errorf("closemu held; should not be") |
