From af1beca9a5360f270a767d3d8772e19d8240ba6d Mon Sep 17 00:00:00 2001
From: Jack Christensen <jack@jackchristensen.com>
Date: Sat, 20 Apr 2019 11:13:26 -0500
Subject: [PATCH] Update pgconn to resolve batch deadlock issue

---
 batch.go | 18 ------------------
 go.mod   |  2 +-
 go.sum   |  2 ++
 3 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/batch.go b/batch.go
index 2307ac32..7d515566 100644
--- a/batch.go
+++ b/batch.go
@@ -59,24 +59,6 @@ func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []pgt
 
 // Send sends all queued queries to the server at once. All queries are run in an implicit transaction unless explicit
 // transaction control statements are executed.
-//
-// Warning: Send writes all queued queries before reading any results. This can
-// cause a deadlock if an excessive number of queries are queued. It is highly
-// advisable to use a timeout context to protect against this possibility.
-// Unfortunately, this excessive number can vary based on operating system,
-// connection type (TCP or Unix domain socket), and type of query. Unix domain
-// sockets seem to be much more susceptible to this issue than TCP connections.
-// However, it usually is at least several thousand.
-//
-// The deadlock occurs when the batched queries to be sent are so large that the
-// PostgreSQL server cannot receive it all at once. PostgreSQL received some of
-// the queued queries and starts executing them. As PostgreSQL executes the
-// queries it sends responses back. pgx will not read any of these responses
-// until it has finished sending. Therefore, if all network buffers are full pgx
-// will not be able to finish sending the queries and PostgreSQL will not be
-// able to finish sending the responses.
-//
-// See https://github.com/jackc/pgx/issues/374.
 func (b *Batch) Send(ctx context.Context) error {
 	if b.err != nil {
 		return b.err
diff --git a/go.mod b/go.mod
index b68872ea..4a50dea2 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.12
 
 require (
 	github.com/cockroachdb/apd v1.1.0
-	github.com/jackc/pgconn v0.0.0-20190419211655-3710e52a9a12
+	github.com/jackc/pgconn v0.0.0-20190420161109-39e6ff5766bd
 	github.com/jackc/pgio v1.0.0
 	github.com/jackc/pgproto3 v1.1.0
 	github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190419041544-9b6a681f50bf
diff --git a/go.sum b/go.sum
index aa5fb34b..913ccbdf 100644
--- a/go.sum
+++ b/go.sum
@@ -14,6 +14,8 @@ github.com/jackc/pgconn v0.0.0-20190419205212-7bb6c2f3e982 h1:U0G6KWiQ9xrqbXt96O
 github.com/jackc/pgconn v0.0.0-20190419205212-7bb6c2f3e982/go.mod h1:UsnoyBN75lNxOeZXUT70J9xAvZffv2fxrxCrIPIH/Rk=
 github.com/jackc/pgconn v0.0.0-20190419211655-3710e52a9a12 h1:PzGjcOqGl6npHTDt8yDK5lnI9/ZQ+5ZpywzazR+yd8Q=
 github.com/jackc/pgconn v0.0.0-20190419211655-3710e52a9a12/go.mod h1:UsnoyBN75lNxOeZXUT70J9xAvZffv2fxrxCrIPIH/Rk=
+github.com/jackc/pgconn v0.0.0-20190420161109-39e6ff5766bd h1:eSKDWtHcm6H/vELPrs6fh7bch3wBc2vUvqVnHw17+5c=
+github.com/jackc/pgconn v0.0.0-20190420161109-39e6ff5766bd/go.mod h1:UsnoyBN75lNxOeZXUT70J9xAvZffv2fxrxCrIPIH/Rk=
 github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
 github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
 github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=