MCPcopy
hub / github.com/jackc/pgx / enterPotentialWriteReadDeadlock

Method enterPotentialWriteReadDeadlock

pgconn/pgconn.go:2107–2117  ·  view source on GitHub ↗

enterPotentialWriteReadDeadlock must be called before a write that could deadlock if the server is simultaneously blocked writing to us.

()

Source from the content-addressed store, hash-verified

2105// enterPotentialWriteReadDeadlock must be called before a write that could deadlock if the server is simultaneously
2106// blocked writing to us.
2107func (pgConn *PgConn) enterPotentialWriteReadDeadlock() {
2108 // The time to wait is somewhat arbitrary. A Write should only take as long as the syscall and memcpy to the OS
2109 // outbound network buffer unless the buffer is full (which potentially is a block). It needs to be long enough for
2110 // the normal case, but short enough not to kill performance if a block occurs.
2111 //
2112 // In addition, on Windows the default timer resolution is 15.6ms. So setting the timer to less than that is
2113 // ineffective.
2114 if pgConn.slowWriteTimer.Reset(15 * time.Millisecond) {
2115 panic("BUG: slow write timer already active")
2116 }
2117}
2118
2119// exitPotentialWriteReadDeadlock must be called after a call to enterPotentialWriteReadDeadlock.
2120func (pgConn *PgConn) exitPotentialWriteReadDeadlock() {

Callers 2

ExecBatchMethod · 0.95

Calls 1

ResetMethod · 0.80

Tested by

no test coverage detected