Skip to content

Commit 3a19891

Browse files
committed
exitPotentialWriteReadDeadlock immediately after Write
Otherwise, a Write error would be handled by pgConn.asyncClose() which would call pgConn.flushWithPotentialWriteReadDeadlock() leading to panic("BUG: slow write timer already active"). #2332
1 parent 91efc19 commit 3a19891

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

pgconn/pgconn.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,9 +1813,11 @@ func (pgConn *PgConn) ExecBatch(ctx context.Context, batch *Batch) *MultiResultR
18131813
return multiResult
18141814
}
18151815

1816-
pgConn.enterPotentialWriteReadDeadlock()
1817-
defer pgConn.exitPotentialWriteReadDeadlock()
1818-
_, err := pgConn.conn.Write(batch.buf)
1816+
_, err := func(buf []byte) (int, error) {
1817+
pgConn.enterPotentialWriteReadDeadlock()
1818+
defer pgConn.exitPotentialWriteReadDeadlock()
1819+
return pgConn.conn.Write(buf)
1820+
}(batch.buf)
18191821
if err != nil {
18201822
pgConn.contextWatcher.Unwatch()
18211823
multiResult.err = normalizeTimeoutError(multiResult.ctx, err)

0 commit comments

Comments
 (0)