Repository: jackc/pgx
Pull request #1679 (2023-07-08 21:50:05)

Add PgConn.SyncConn
This provides a way to ensure it is safe to directly read or write to the underlying net.Conn.

https://github.com/jackc/pgx/issues/1673

---

Unfortunately, I'm not sure of a good way to test this as I don't know of a sure way to cause the conditions that `SyncConn` removes.

jackc: Huh. Not sure that test is failing.

Patch:
diff --git a/examples/url_shortener/main.go b/examples/url_shortener/main.go
index 12195922..0887a019 100644
--- a/examples/url_shortener/main.go
+++ b/examples/url_shortener/main.go
@@ -2,7 +2,7 @@ package main
 
 import (
 	"context"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"os"
@@ -29,7 +29,7 @@ func getUrlHandler(w http.ResponseWriter, req *http.Request) {
 func putUrlHandler(w http.ResponseWriter, req *http.Request) {
 	id := req.URL.Path
 	var url string
-	if body, err := ioutil.ReadAll(req.Body); err == nil {
+	if body, err := io.ReadAll(req.Body); err == nil {
 		url = string(body)
 	} else {
 		http.Error(w, "Internal server error", http.StatusInternalServerError)
diff --git a/pgconn/internal/bgreader/bgreader.go b/pgconn/internal/bgreader/bgreader.go
index aa1a3d39..e65c2c2b 100644
--- a/pgconn/internal/bgreader/bgreader.go
+++ b/pgconn/internal/bgreader/bgreader.go
@@ -9,18 +9,18 @@ import (
 )
 
 const (
-	bgReaderStatusStopped = iota
-	bgReaderStatusRunning
-	bgReaderStatusStopping
+	StatusStopped = iota
+	StatusRunning
+	StatusStopping
 )
 
 // BGReader is an io.Reader that can optionally buffer reads in the background. It is safe for concurrent use.
 type BGReader struct {
 	r io.Reader
 
-	cond           *sync.Cond
-	bgReaderStatus int32
-	readResults    []readResult
+	cond        *sync.Cond
+	status      int32
+	readResults []readResult
 }
 
 type readResult struct {
@@ -34,14 +34,14 @@ func (r *BGReader) Start() {
 	r.cond.L.Lock()
 	defer r.cond.L.Unlock()
 
-	switch r.bgReaderStatus {
-	case bgReaderStatusStopped:
-		r.bgReaderStatus = bgReaderStatusRunning
+	switch r.status {
+	case StatusStopped:
+		r.status = StatusRunning
 		go r.bgRead()
-	case bgReaderStatusRunning:
+	case StatusRunning:
 		// no-op
-	case bgReaderStatusStopping:
-		r.bgReaderStatus = bgReaderStatusRunning
+	case StatusStopping:
+		r.status = StatusRunning
 	}
 }
 
@@ -51,16 +51,23 @@ func (r *BGReader) Stop() {
 	r.cond.L.Lock()
 	defer r.cond.L.Unlock()
 
-	switch r.bgReaderStatus {
-	case bgReaderStatusStopped:
+	switch r.status {
+	case StatusStopped:
 		// no-op
-	case bgReaderStatusRunning:
-		r.bgReaderStatus = bgReaderStatusStopping
-	case bgReaderStatusStopping:
+	case StatusRunning:
+		r.status = StatusStopping
+	case StatusStopping:
 		// no-op
 	}
 }
 
+// Status returns the current status of the background reader.
+func (r *BGReader) Status() int32 {
+	r.cond.L.Lock()
+	defer r.cond.L.Unlock()
+	return r.status
+}
+
 func (r *BGReader) bgRead() {
 	keepReading := true
 	for keepReading {
@@ -70,8 +77,8 @@ func (r *BGReader) bgRead() {
 
 		r.cond.L.Lock()
 		r.readResults = append(r.readResults, readResult{buf: buf, err: err})
-		if r.bgReaderStatus == bgReaderStatusStopping || err != nil {
-			r.bgReaderStatus = bgReaderStatusStopped
+		if r.status == StatusStopping || err != nil {
+			r.status = StatusStopped
 			keepReading = false
 		}
 		r.cond.L.Unlock()
@@ -89,7 +96,7 @@ func (r *BGReader) Read(p []byte) (int, error) {
 	}
 
 	// There are no unread background read results and the background reader is stopped.
-	if r.bgReaderStatus == bgReaderStatusStopped {
+	if r.status == StatusStopped {
 		return r.r.Read(p)
 	}
 
diff --git a/pgconn/pgconn.go b/pgconn/pgconn.go
index 8a9f80a6..12357751 100644
--- a/pgconn/pgconn.go
+++ b/pgconn/pgconn.go
@@ -556,7 +556,8 @@ func (pgConn *PgConn) receiveMessage() (pgproto3.BackendMessage, error) {
 	return msg, nil
 }
 
-// Conn returns the underlying net.Conn. This rarely necessary.
+// Conn returns the underlying net.Conn. This rarely necessary. If the connection will be directly used for reading or
+// writing then SyncConn should usually be called before Conn.
 func (pgConn *PgConn) Conn() net.Conn {
 	return pgConn.conn
 }
@@ -1731,6 +1732,7 @@ func (pgConn *PgConn) exitPotentialWriteReadDeadlock() {
 	// The state of the timer is not relevant upon exiting the potential slow write. It may both
 	// fire (due to a slow write), or not fire (due to a fast write).
 	_ = pgConn.slowWriteTimer.Stop()
+	pgConn.bgReader.Stop()
 }
 
 func (pgConn *PgConn) flushWithPotentialWriteReadDeadlock() error {
@@ -1740,6 +1742,30 @@ func (pgConn *PgConn) flushWithPotentialWriteReadDeadlock() error {
 	return err
 }
 
+// SyncConn prepares the underlying net.Conn for direct use. PgConn may internally buffer reads or use goroutines for
+// background IO. This means that any direct use of the underlying net.Conn may be corrupted if a read is already
+// buffered or a read is in progress. SyncConn drains read buffers and stops background IO. In some cases this may
+// require sending a ping to the server. ctx can be used to cancel this operation. This should be called before any
+// operation that will use the underlying net.Conn directly. e.g. Before Conn() or Hijack().
+//
+// This should not be confused with the PostgreSQL protocol Sync message.
+func (pgConn *PgConn) SyncConn(ctx context.Context) error {
+	for i := 0; i < 10; i++ {
+		if pgConn.bgReader.Status() == bgreader.StatusStopped && pgConn.frontend.ReadBufferLen() == 0 {
+			return nil
+		}
+
+		err := pgConn.Ping(ctx)
+		if err != nil {
+			return fmt.Errorf("SyncConn: Ping failed while syncing conn: %w", err)
+		}
+	}
+
+	// This should never happen. Only way I can imagine this occuring is if the server is constantly sending data such as
+	// LISTEN/NOTIFY or log notifications such that we never can get an empty buffer.
+	return errors.New("SyncConn: conn never synchronized")
+}
+
 // HijackedConn is the result of hijacking a connection.
 //
 // Due to the necessary exposure of internal implementation details, it is not covered by the semantic versioning
@@ -1754,9 +1780,9 @@ type HijackedConn struct {
 	Config            *Config
 }
 
-// Hijack extracts the internal connection data. pgConn must be in an idle state. pgConn is unusable after hijacking.
-// Hijacking is typically only useful when using pgconn to establish a connection, but taking complete control of the
-// raw connection after that (e.g. a load balancer or proxy).
+// Hijack extracts the internal connection data. pgConn must be in an idle state. SyncConn should be called immediately
+// before Hijack. pgConn is unusable after hijacking. Hijacking is typically only useful when using pgconn to establish
+// a connection, but taking complete control of the raw connection after that (e.g. a load balancer or proxy).
 //
 // Due to the necessary exposure of internal implementation details, it is not covered by the semantic versioning
 // compatibility.
diff --git a/pgproto3/frontend.go b/pgproto3/frontend.go
index 83dea963..33c3882a 100644
--- a/pgproto3/frontend.go
+++ b/pgproto3/frontend.go
@@ -361,3 +361,7 @@ func (f *Frontend) findAuthenticationMessageType(src []byte) (BackendMessage, er
 func (f *Frontend) GetAuthType() uint32 {
 	return f.authType
 }
+
+func (f *Frontend) ReadBufferLen() int {
+	return f.cr.wp - f.cr.rp
+}
diff --git a/pgtype/array.go b/pgtype/array.go
index 7dfee389..73761956 100644
--- a/pgtype/array.go
+++ b/pgtype/array.go
@@ -5,7 +5,6 @@ import (
 	"encoding/binary"
 	"fmt"
 	"io"
-	"reflect"
 	"strconv"
 	"strings"
 	"unicode"
@@ -375,27 +374,6 @@ func quoteArrayElementIfNeeded(src string) string {
 	return src
 }
 
-func findDimensionsFromValue(value reflect.Value, dimensions []ArrayDimension, elementsLength int) ([]ArrayDimension, int, bool) {
-	switch value.Kind() {
-	case reflect.Array:
-		fallthrough
-	case reflect.Slice:
-		length := value.Len()
-		if 0 == elementsLength {
-			elementsLength = length
-		} else {
-			elementsLength *= length
-		}
-		dimensions = append(dimensions, ArrayDimension{Length: int32(length), LowerBound: 1})
-		for i := 0; i < length; i++ {
-			if d, l, ok := findDimensionsFromValue(value.Index(i), dimensions, elementsLength); ok {
-				return d, l, true
-			}
-		}
-	}
-	return dimensions, elementsLength, true
-}
-
 // Array represents a PostgreSQL array for T. It implements the ArrayGetter and ArraySetter interfaces. It preserves
 // PostgreSQL dimensions and custom lower bounds. Use FlatArray if these are not needed.
 type Array[T any] struct {
diff --git a/pgtype/convert.go b/pgtype/convert.go
index 7fddeaa8..8a9cee9c 100644
--- a/pgtype/convert.go
+++ b/pgtype/convert.go
@@ -1,380 +1,9 @@
 package pgtype
 
 import (
-	"database/sql"
-	"fmt"
-	"math"
 	"reflect"
-	"time"
 )
 
-const (
-	maxUint = ^uint(0)
-	maxInt  = int(maxUint >> 1)
-	minInt  = -maxInt - 1
-)
-
-// underlyingNumberType gets the underlying type that can be converted to Int2, Int4, Int8, Float4, or Float8
-func underlyingNumberType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	case reflect.Int:
-		convVal := int(refVal.Int())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Int8:
-		convVal := int8(refVal.Int())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Int16:
-		convVal := int16(refVal.Int())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Int32:
-		convVal := int32(refVal.Int())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Int64:
-		convVal := int64(refVal.Int())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Uint:
-		convVal := uint(refVal.Uint())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Uint8:
-		convVal := uint8(refVal.Uint())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Uint16:
-		convVal := uint16(refVal.Uint())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Uint32:
-		convVal := uint32(refVal.Uint())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Uint64:
-		convVal := uint64(refVal.Uint())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Float32:
-		convVal := float32(refVal.Float())
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Float64:
-		convVal := refVal.Float()
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.String:
-		convVal := refVal.String()
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	case reflect.Bool:
-		convVal := refVal.Bool()
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	}
-
-	return nil, false
-}
-
-// underlyingBoolType gets the underlying type that can be converted to Bool
-func underlyingBoolType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	case reflect.Bool:
-		convVal := refVal.Bool()
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	}
-
-	return nil, false
-}
-
-// underlyingBytesType gets the underlying type that can be converted to []byte
-func underlyingBytesType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	case reflect.Slice:
-		if refVal.Type().Elem().Kind() == reflect.Uint8 {
-			convVal := refVal.Bytes()
-			return convVal, reflect.TypeOf(convVal) != refVal.Type()
-		}
-	}
-
-	return nil, false
-}
-
-// underlyingStringType gets the underlying type that can be converted to String
-func underlyingStringType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	case reflect.String:
-		convVal := refVal.String()
-		return convVal, reflect.TypeOf(convVal) != refVal.Type()
-	}
-
-	return nil, false
-}
-
-// underlyingPtrType dereferences a pointer
-func underlyingPtrType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	}
-
-	return nil, false
-}
-
-// underlyingTimeType gets the underlying type that can be converted to time.Time
-func underlyingTimeType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	}
-
-	timeType := reflect.TypeOf(time.Time{})
-	if refVal.Type().ConvertibleTo(timeType) {
-		return refVal.Convert(timeType).Interface(), true
-	}
-
-	return nil, false
-}
-
-// underlyingUUIDType gets the underlying type that can be converted to [16]byte
-func underlyingUUIDType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return time.Time{}, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	}
-
-	uuidType := reflect.TypeOf([16]byte{})
-	if refVal.Type().ConvertibleTo(uuidType) {
-		return refVal.Convert(uuidType).Interface(), true
-	}
-
-	return nil, false
-}
-
-// underlyingSliceType gets the underlying slice type
-func underlyingSliceType(val any) (any, bool) {
-	refVal := reflect.ValueOf(val)
-
-	switch refVal.Kind() {
-	case reflect.Ptr:
-		if refVal.IsNil() {
-			return nil, false
-		}
-		convVal := refVal.Elem().Interface()
-		return convVal, true
-	case reflect.Slice:
-		baseSliceType := reflect.SliceOf(refVal.Type().Elem())
-		if refVal.Type().ConvertibleTo(baseSliceType) {
-			convVal := refVal.Convert(baseSliceType)
-			return convVal.Interface(), reflect.TypeOf(convVal.Interface()) != refVal.Type()
-		}
-	}
-
-	return nil, false
-}
-
-func int64AssignTo(srcVal int64, srcValid bool, dst any) error {
-	if srcValid {
-		switch v := dst.(type) {
-		case *int:
-			if srcVal < int64(minInt) {
-				return fmt.Errorf("%d is less than minimum value for int", srcVal)
-			} else if srcVal > int64(maxInt) {
-				return fmt.Errorf("%d is greater than maximum value for int", srcVal)
-			}
-			*v = int(srcVal)
-		case *int8:
-			if srcVal < math.MinInt8 {
-				return fmt.Errorf("%d is less than minimum value for int8", srcVal)
-			} else if srcVal > math.MaxInt8 {
-				return fmt.Errorf("%d is greater than maximum value for int8", srcVal)
-			}
-			*v = int8(srcVal)
-		case *int16:
-			if srcVal < math.MinInt16 {
-				return fmt.Errorf("%d is less than minimum value for int16", srcVal)
-			} else if srcVal > math.MaxInt16 {
-				return fmt.Errorf("%d is greater than maximum value for int16", srcVal)
-			}
-			*v = int16(srcVal)
-		case *int32:
-			if srcVal < math.MinInt32 {
-				return fmt.Errorf("%d is less than minimum value for int32", srcVal)
-			} else if srcVal > math.MaxInt32 {
-				return fmt.Errorf("%d is greater than maximum value for int32", srcVal)
-			}
-			*v = int32(srcVal)
-		case *int64:
-			if srcVal < math.MinInt64 {
-				return fmt.Errorf("%d is less than minimum value for int64", srcVal)
-			} else if srcVal > math.MaxInt64 {
-				return fmt.Errorf("%d is greater than maximum value for int64", srcVal)
-			}
-			*v = int64(srcVal)
-		case *uint:
-			if srcVal < 0 {
-				return fmt.Errorf("%d is less than zero for uint", srcVal)
-			} else if uint64(srcVal) > uint64(maxUint) {
-				return fmt.Errorf("%d is greater than maximum value for uint", srcVal)
-			}
-			*v = uint(srcVal)
-		case *uint8:
-			if srcVal < 0 {
-				return fmt.Errorf("%d is less than zero for uint8", srcVal)
-			} else if srcVal > math.MaxUint8 {
-				return fmt.Errorf("%d is greater than maximum value for uint8", srcVal)
-			}
-			*v = uint8(srcVal)
-		case *uint16:
-			if srcVal < 0 {
-				return fmt.Errorf("%d is less than zero for uint16", srcVal)
-			} else if srcVal > math.MaxUint16 {
-				return fmt.Errorf("%d is greater than maximum value for uint16", srcVal)
-			}
-			*v = uint16(srcVal)
-		case *uint32:
-			if srcVal < 0 {
-				return fmt.Errorf("%d is less than zero for uint32", srcVal)
-			} else if srcVal > math.MaxUint32 {
-				return fmt.Errorf("%d is greater than maximum value for uint32", srcVal)
-			}
-			*v = uint32(srcVal)
-		case *uint64:
-			if srcVal < 0 {
-				return fmt.Errorf("%d is less than zero for uint64", srcVal)
-			}
-			*v = uint64(srcVal)
-		case sql.Scanner:
-			return v.Scan(srcVal)
-		default:
-			if v := reflect.ValueOf(dst); v.Kind() == reflect.Ptr {
-				el := v.Elem()
-				switch el.Kind() {
-				// if dst is a pointer to pointer, strip the pointer and try again
-				case reflect.Ptr:
-					if el.IsNil() {
-						// allocate destination
-						el.Set(reflect.New(el.Type().Elem()))
-					}
-					return int64AssignTo(srcVal, srcValid, el.Interface())
-				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-					if el.OverflowInt(int64(srcVal)) {
-						return fmt.Errorf("cannot put %d into %T", srcVal, dst)
-					}
-					el.SetInt(int64(srcVal))
-					return nil
-				case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
-					if srcVal < 0 {
-						return fmt.Errorf("%d is less than zero for %T", srcVal, dst)
-					}
-					if el.OverflowUint(uint64(srcVal)) {
-						return fmt.Errorf("cannot put %d into %T", srcVal, dst)
-					}
-					el.SetUint(uint64(srcVal))
-					return nil
-				}
-			}
-			return fmt.Errorf("cannot assign %v into %T", srcVal, dst)
-		}
-		return nil
-	}
-
-	// if dst is a pointer to pointer and srcStatus is not Valid, nil it out
-	if v := reflect.ValueOf(dst); v.Kind() == reflect.Ptr {
-		el := v.Elem()
-		if el.Kind() == reflect.Ptr {
-			el.Set(reflect.Zero(el.Type()))
-			return nil
-		}
-	}
-
-	return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst)
-}
-
-func float64AssignTo(srcVal float64, srcValid bool, dst any) error {
-	if srcValid {
-		switch v := dst.(type) {
-		case *float32:
-			*v = float32(srcVal)
-		case *float64:
-			*v = srcVal
-		default:
-			if v := reflect.ValueOf(dst); v.Kind() == reflect.Ptr {
-				el := v.Elem()
-				switch el.Kind() {
-				// if dst is a type alias of a float32 or 64, set dst val
-				case reflect.Float32, reflect.Float64:
-					el.SetFloat(srcVal)
-					return nil
-				// if dst is a pointer to pointer, strip the pointer and try again
-				case reflect.Ptr:
-					if el.IsNil() {
-						// allocate destination
-						el.Set(reflect.New(el.Type().Elem()))
-					}
-					return float64AssignTo(srcVal, srcValid, el.Interface())
-				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
-					i64 := int64(srcVal)
-					if float64(i64) == srcVal {
-						return int64AssignTo(i64, srcValid, dst)
-					}
-				}
-			}
-			return fmt.Errorf("cannot assign %v into %T", srcVal, dst)
-		}
-		return nil
-	}
-
-	// if dst is a pointer to pointer and srcStatus is not Valid, nil it out
-	if v := reflect.ValueOf(dst); v.Kind() == reflect.Ptr {
-		el := v.Elem()
-		if el.Kind() == reflect.Ptr {
-			el.Set(reflect.Zero(el.Type()))
-			return nil
-		}
-	}
-
-	return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst)
-}
-
 func NullAssignTo(dst any) error {
 	dstPtr := reflect.ValueOf(dst)
 
diff --git a/pgtype/json.go b/pgtype/json.go
index 753f2410..b7a7101e 100644
--- a/pgtype/json.go
+++ b/pgtype/json.go
@@ -25,6 +25,13 @@ func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value any) Encod
 	case []byte:
 		return encodePlanJSONCodecEitherFormatByteSlice{}
 
+	// Must come before trying wrap encode plans because a pointer to a struct may be unwrapped to a struct that can be
+	// marshalled.
+	//
+	// https://github.com/jackc/pgx/issues/1681
+	case json.Marshaler:
+		return encodePlanJSONCodecEitherFormatMarshal{}
+
 	// Cannot rely on driver.Valuer being handled later because anything can be marshalled.
 	//
 	// https://github.com/jackc/pgx/issues/1430
diff --git a/pgtype/numeric.go b/pgtype/numeric.go
index 4e0ccc9a..62e45787 100644
--- a/pgtype/numeric.go
+++ b/pgtype/numeric.go
@@ -33,23 +33,6 @@ var big10 *big.Int = big.NewInt(10)
 var big100 *big.Int = big.NewInt(100)
 var big1000 *big.Int = big.NewInt(1000)
 
-var bigMaxInt8 *big.Int = big.NewInt(math.MaxInt8)
-var bigMinInt8 *big.Int = big.NewInt(math.MinInt8)
-var bigMaxInt16 *big.Int = big.NewInt(math.MaxInt16)
-var bigMinInt16 *big.Int = big.NewInt(math.MinInt16)
-var bigMaxInt32 *big.Int = big.NewInt(math.MaxInt32)
-var bigMinInt32 *big.Int = big.NewInt(math.MinInt32)
-var bigMaxInt64 *big.Int = big.NewInt(math.MaxInt64)
-var bigMinInt64 *big.Int = big.NewInt(math.MinInt64)
-var bigMaxInt *big.Int = big.NewInt(int64(maxInt))
-var bigMinInt *big.Int = big.NewInt(int64(minInt))
-
-var bigMaxUint8 *big.Int = big.NewInt(math.MaxUint8)
-var bigMaxUint16 *big.Int = big.NewInt(math.MaxUint16)
-var bigMaxUint32 *big.Int = big.NewInt(math.MaxUint32)
-var bigMaxUint64 *big.Int = (&big.Int{}).SetUint64(uint64(math.MaxUint64))
-var bigMaxUint *big.Int = (&big.Int{}).SetUint64(uint64(maxUint))
-
 var bigNBase *big.Int = big.NewInt(nbase)
 var bigNBaseX2 *big.Int = big.NewInt(nbase * nbase)
 var bigNBaseX3 *big.Int = big.NewInt(nbase * nbase * nbase)
diff --git a/pgtype/pgtype.go b/pgtype/pgtype.go
index b9cd7b41..8b636763 100644
--- a/pgtype/pgtype.go
+++ b/pgtype/pgtype.go
@@ -1140,25 +1140,6 @@ func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst any) error {
 	return plan.Scan(src, dst)
 }
 
-func scanUnknownType(oid uint32, formatCode int16, buf []byte, dest any) error {
-	switch dest := dest.(type) {
-	case *string:
-		if formatCode == BinaryFormatCode {
-			return fmt.Errorf("unknown oid %d in binary format cannot be scanned into %T", oid, dest)
-		}
-		*dest = string(buf)
-		return nil
-	case *[]byte:
-		*dest = buf
-		return nil
-	default:
-		if nextDst, retry := GetAssignToDstType(dest); retry {
-			return scanUnknownType(oid, formatCode, buf, nextDst)
-		}
-		return fmt.Errorf("unknown oid %d cannot be scanned into %T", oid, dest)
-	}
-}
-
 var ErrScanTargetTypeChanged = errors.New("scan target type changed")
 
 func codecScan(codec Codec, m *Map, oid uint32, format int16, src []byte, dst any) error {


Test patch:
diff --git a/batch_test.go b/batch_test.go
index 8d38f466..9ff2417f 100644
--- a/batch_test.go
+++ b/batch_test.go
@@ -18,7 +18,7 @@ import (
 func TestConnSendBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -156,7 +156,7 @@ func TestConnSendBatch(t *testing.T) {
 func TestConnSendBatchQueuedQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -252,7 +252,7 @@ func TestConnSendBatchQueuedQuery(t *testing.T) {
 func TestConnSendBatchMany(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -300,7 +300,7 @@ func TestConnSendBatchWithPreparedStatement(t *testing.T) {
 		pgx.QueryExecModeExec,
 		// Don't test simple mode with prepared statements.
 	}
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, modes, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -350,7 +350,7 @@ func TestConnSendBatchWithPreparedStatement(t *testing.T) {
 func TestConnSendBatchWithQueryRewriter(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -384,7 +384,7 @@ func TestConnSendBatchWithQueryRewriter(t *testing.T) {
 func TestConnSendBatchWithPreparedStatementAndStatementCacheDisabled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgx.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -445,7 +445,7 @@ func TestConnSendBatchWithPreparedStatementAndStatementCacheDisabled(t *testing.
 func TestConnSendBatchCloseRowsPartiallyRead(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -507,7 +507,7 @@ func TestConnSendBatchCloseRowsPartiallyRead(t *testing.T) {
 func TestConnSendBatchQueryError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -548,7 +548,7 @@ func TestConnSendBatchQueryError(t *testing.T) {
 func TestConnSendBatchQuerySyntaxError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -575,7 +575,7 @@ func TestConnSendBatchQuerySyntaxError(t *testing.T) {
 func TestConnSendBatchQueryRowInsert(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -615,7 +615,7 @@ func TestConnSendBatchQueryRowInsert(t *testing.T) {
 func TestConnSendBatchQueryPartialReadInsert(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -655,7 +655,7 @@ func TestConnSendBatchQueryPartialReadInsert(t *testing.T) {
 func TestTxSendBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -725,7 +725,7 @@ func TestTxSendBatch(t *testing.T) {
 func TestTxSendBatchRollback(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -764,7 +764,7 @@ func TestTxSendBatchRollback(t *testing.T) {
 func TestSendBatchErrorWhileReadingResultsWithoutCallback(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -788,7 +788,7 @@ func TestSendBatchErrorWhileReadingResultsWithoutCallback(t *testing.T) {
 func TestSendBatchErrorWhileReadingResultsWithExecWhereSomeRowsAreReturned(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -812,7 +812,7 @@ func TestSendBatchErrorWhileReadingResultsWithExecWhereSomeRowsAreReturned(t *te
 func TestConnBeginBatchDeferredError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -860,7 +860,7 @@ func TestConnBeginBatchDeferredError(t *testing.T) {
 }
 
 func TestConnSendBatchNoStatementCache(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -875,7 +875,7 @@ func TestConnSendBatchNoStatementCache(t *testing.T) {
 }
 
 func TestConnSendBatchPrepareStatementCache(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -889,7 +889,7 @@ func TestConnSendBatchPrepareStatementCache(t *testing.T) {
 }
 
 func TestConnSendBatchDescribeStatementCache(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -931,7 +931,7 @@ func testConnSendBatch(t *testing.T, ctx context.Context, conn *pgx.Conn, queryC
 func TestSendBatchSimpleProtocol(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -970,7 +970,7 @@ func TestSendBatchSimpleProtocol(t *testing.T) {
 }
 
 func ExampleConn_SendBatch() {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/conn_test.go b/conn_test.go
index 25cab7a1..4c35b648 100644
--- a/conn_test.go
+++ b/conn_test.go
@@ -215,7 +215,7 @@ func TestParseConfigErrors(t *testing.T) {
 func TestExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -261,7 +261,7 @@ func (qr *testQueryRewriter) RewriteQuery(ctx context.Context, conn *pgx.Conn, s
 func TestExecWithQueryRewriter(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -274,7 +274,7 @@ func TestExecWithQueryRewriter(t *testing.T) {
 func TestExecFailure(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -293,7 +293,7 @@ func TestExecFailure(t *testing.T) {
 func TestExecFailureWithArguments(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -311,7 +311,7 @@ func TestExecFailureWithArguments(t *testing.T) {
 func TestExecContextWithoutCancelation(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -332,7 +332,7 @@ func TestExecContextWithoutCancelation(t *testing.T) {
 func TestExecContextFailureWithoutCancelation(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -357,7 +357,7 @@ func TestExecContextFailureWithoutCancelation(t *testing.T) {
 func TestExecContextFailureWithoutCancelationWithArguments(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -512,7 +512,7 @@ func TestPrepareIdempotency(t *testing.T) {
 func TestPrepareStatementCacheModes(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -755,7 +755,7 @@ func TestFatalTxError(t *testing.T) {
 func TestInsertBoolArray(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -773,7 +773,7 @@ func TestInsertBoolArray(t *testing.T) {
 func TestInsertTimestampArray(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -858,7 +858,7 @@ func TestConnInitTypeMap(t *testing.T) {
 }
 
 func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -877,7 +877,7 @@ func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) {
 }
 
 func TestDomainType(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -914,7 +914,7 @@ func TestDomainType(t *testing.T) {
 }
 
 func TestLoadTypeSameNameInDifferentSchemas(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -959,7 +959,7 @@ create type pgx_b.point as (c text);
 }
 
 func TestLoadCompositeType(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -981,7 +981,7 @@ func TestLoadCompositeType(t *testing.T) {
 }
 
 func TestLoadRangeType(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -1015,7 +1015,7 @@ func TestLoadRangeType(t *testing.T) {
 }
 
 func TestLoadMultiRangeType(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -1205,7 +1205,7 @@ func TestStmtCacheInvalidationTx(t *testing.T) {
 }
 
 func TestInsertDurationInterval(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
diff --git a/copy_from_test.go b/copy_from_test.go
index ce933de2..e17fb470 100644
--- a/copy_from_test.go
+++ b/copy_from_test.go
@@ -17,7 +17,7 @@ import (
 func TestConnCopyWithAllQueryExecModes(t *testing.T) {
 	for _, mode := range pgxtest.AllQueryExecModes {
 		t.Run(mode.String(), func(t *testing.T) {
-			ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+			ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 			defer cancel()
 
 			cfg := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -79,7 +79,7 @@ func TestConnCopyWithKnownOIDQueryExecModes(t *testing.T) {
 
 	for _, mode := range pgxtest.KnownOIDQueryExecModes {
 		t.Run(mode.String(), func(t *testing.T) {
-			ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+			ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 			defer cancel()
 
 			cfg := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -142,7 +142,7 @@ func TestConnCopyWithKnownOIDQueryExecModes(t *testing.T) {
 func TestConnCopyFromSmall(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -201,7 +201,7 @@ func TestConnCopyFromSmall(t *testing.T) {
 func TestConnCopyFromSliceSmall(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -263,7 +263,7 @@ func TestConnCopyFromSliceSmall(t *testing.T) {
 func TestConnCopyFromLarge(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -326,7 +326,7 @@ func TestConnCopyFromLarge(t *testing.T) {
 func TestConnCopyFromEnum(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -400,7 +400,7 @@ func TestConnCopyFromEnum(t *testing.T) {
 func TestConnCopyFromJSON(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -480,7 +480,7 @@ func (cfs *clientFailSource) Err() error {
 func TestConnCopyFromFailServerSideMidway(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -559,7 +559,7 @@ func (fs *failSource) Err() error {
 func TestConnCopyFromFailServerSideMidwayAbortsWithoutWaiting(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -639,7 +639,7 @@ func (fs *slowFailRaceSource) Err() error {
 func TestConnCopyFromSlowFailRace(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -667,7 +667,7 @@ func TestConnCopyFromSlowFailRace(t *testing.T) {
 func TestConnCopyFromCopyFromSourceErrorMidway(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -730,7 +730,7 @@ func (cfs *clientFinalErrSource) Err() error {
 func TestConnCopyFromCopyFromSourceErrorEnd(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -776,7 +776,7 @@ func TestConnCopyFromCopyFromSourceErrorEnd(t *testing.T) {
 func TestConnCopyFromAutomaticStringConversion(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/large_objects_test.go b/large_objects_test.go
index 626809e7..25611bf6 100644
--- a/large_objects_test.go
+++ b/large_objects_test.go
@@ -15,7 +15,7 @@ import (
 func TestLargeObjects(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -36,7 +36,7 @@ func TestLargeObjects(t *testing.T) {
 func TestLargeObjectsSimpleProtocol(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgx.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -162,7 +162,7 @@ func testLargeObjects(t *testing.T, ctx context.Context, tx pgx.Tx) {
 func TestLargeObjectsMultipleTransactions(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/pgconn/helper_test.go b/pgconn/helper_test.go
index 0696f4ce..1ab7579a 100644
--- a/pgconn/helper_test.go
+++ b/pgconn/helper_test.go
@@ -12,19 +12,19 @@ import (
 )
 
 func closeConn(t testing.TB, conn *pgconn.PgConn) {
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
 	defer cancel()
 	require.NoError(t, conn.Close(ctx))
 	select {
 	case <-conn.CleanupDone():
-	case <-time.After(5 * time.Second):
+	case <-time.After(30 * time.Second):
 		t.Fatal("Connection cleanup exceeded maximum time")
 	}
 }
 
 // Do a simple query to ensure the connection is still usable
 func ensureConnValid(t *testing.T, pgConn *pgconn.PgConn) {
-	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
 	result := pgConn.ExecParams(ctx, "select generate_series(1,$1)", [][]byte{[]byte("3")}, nil, nil, nil).Read()
 	cancel()
 
diff --git a/pgconn/pgconn_test.go b/pgconn/pgconn_test.go
index 93afcbfe..37a5512c 100644
--- a/pgconn/pgconn_test.go
+++ b/pgconn/pgconn_test.go
@@ -42,7 +42,7 @@ func TestConnect(t *testing.T) {
 	for _, tt := range tests {
 		tt := tt
 		t.Run(tt.name, func(t *testing.T) {
-			ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+			ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 			defer cancel()
 
 			connString := os.Getenv(tt.env)
@@ -73,7 +73,7 @@ func TestConnectWithOptions(t *testing.T) {
 	for _, tt := range tests {
 		tt := tt
 		t.Run(tt.name, func(t *testing.T) {
-			ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+			ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 			defer cancel()
 
 			connString := os.Getenv(tt.env)
@@ -95,7 +95,7 @@ func TestConnectWithOptions(t *testing.T) {
 func TestConnectTLS(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TLS_CONN_STRING")
@@ -118,7 +118,7 @@ func TestConnectTLS(t *testing.T) {
 func TestConnectTLSPasswordProtectedClientCertWithSSLPassword(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TLS_CLIENT_CONN_STRING")
@@ -146,7 +146,7 @@ func TestConnectTLSPasswordProtectedClientCertWithSSLPassword(t *testing.T) {
 func TestConnectTLSPasswordProtectedClientCertWithGetSSLPasswordConfigOption(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TLS_CLIENT_CONN_STRING")
@@ -342,7 +342,7 @@ func TestConnectTimeoutStuckOnTLSHandshake(t *testing.T) {
 func TestConnectInvalidUser(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TCP_CONN_STRING")
@@ -369,7 +369,7 @@ func TestConnectInvalidUser(t *testing.T) {
 func TestConnectWithConnectionRefused(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	// Presumably nothing is listening on 127.0.0.1:1
@@ -383,7 +383,7 @@ func TestConnectWithConnectionRefused(t *testing.T) {
 func TestConnectCustomDialer(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -404,7 +404,7 @@ func TestConnectCustomDialer(t *testing.T) {
 func TestConnectCustomLookup(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TCP_CONN_STRING")
@@ -430,7 +430,7 @@ func TestConnectCustomLookup(t *testing.T) {
 func TestConnectCustomLookupWithPort(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_TCP_CONN_STRING")
@@ -467,7 +467,7 @@ func TestConnectCustomLookupWithPort(t *testing.T) {
 func TestConnectWithRuntimeParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -496,7 +496,7 @@ func TestConnectWithRuntimeParams(t *testing.T) {
 func TestConnectWithFallback(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -532,7 +532,7 @@ func TestConnectWithFallback(t *testing.T) {
 func TestConnectWithValidateConnect(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -574,7 +574,7 @@ func TestConnectWithValidateConnect(t *testing.T) {
 func TestConnectWithValidateConnectTargetSessionAttrsReadWrite(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -592,7 +592,7 @@ func TestConnectWithValidateConnectTargetSessionAttrsReadWrite(t *testing.T) {
 func TestConnectWithAfterConnect(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -616,7 +616,7 @@ func TestConnectWithAfterConnect(t *testing.T) {
 func TestConnectConfigRequiresConfigFromParseConfig(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config := &pgconn.Config{}
@@ -627,7 +627,7 @@ func TestConnectConfigRequiresConfigFromParseConfig(t *testing.T) {
 func TestConnPrepareSyntaxError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -644,7 +644,7 @@ func TestConnPrepareSyntaxError(t *testing.T) {
 func TestConnPrepareContextPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -665,7 +665,7 @@ func TestConnPrepareContextPrecanceled(t *testing.T) {
 func TestConnExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -687,7 +687,7 @@ func TestConnExec(t *testing.T) {
 func TestConnExecEmpty(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -711,7 +711,7 @@ func TestConnExecEmpty(t *testing.T) {
 func TestConnExecMultipleQueries(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -739,7 +739,7 @@ func TestConnExecMultipleQueries(t *testing.T) {
 func TestConnExecMultipleQueriesEagerFieldDescriptions(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -770,7 +770,7 @@ func TestConnExecMultipleQueriesEagerFieldDescriptions(t *testing.T) {
 func TestConnExecMultipleQueriesError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -804,7 +804,7 @@ func TestConnExecMultipleQueriesError(t *testing.T) {
 func TestConnExecDeferredError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -839,7 +839,7 @@ func TestConnExecDeferredError(t *testing.T) {
 func TestConnExecContextCanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -867,7 +867,7 @@ func TestConnExecContextCanceled(t *testing.T) {
 func TestConnExecContextPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -886,7 +886,7 @@ func TestConnExecContextPrecanceled(t *testing.T) {
 func TestConnExecParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -913,7 +913,7 @@ func TestConnExecParams(t *testing.T) {
 func TestConnExecParamsDeferredError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -947,7 +947,7 @@ func TestConnExecParamsDeferredError(t *testing.T) {
 func TestConnExecParamsMaxNumberOfParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -973,7 +973,7 @@ func TestConnExecParamsMaxNumberOfParams(t *testing.T) {
 func TestConnExecParamsTooManyParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -999,7 +999,7 @@ func TestConnExecParamsTooManyParams(t *testing.T) {
 func TestConnExecParamsCanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1030,7 +1030,7 @@ func TestConnExecParamsCanceled(t *testing.T) {
 func TestConnExecParamsPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1049,7 +1049,7 @@ func TestConnExecParamsPrecanceled(t *testing.T) {
 func TestConnExecParamsEmptySQL(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1068,7 +1068,7 @@ func TestConnExecParamsEmptySQL(t *testing.T) {
 func TestResultReaderValuesHaveSameCapacityAsLength(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1096,7 +1096,7 @@ func TestResultReaderValuesHaveSameCapacityAsLength(t *testing.T) {
 func TestConnExecPrepared(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1129,7 +1129,7 @@ func TestConnExecPrepared(t *testing.T) {
 func TestConnExecPreparedMaxNumberOfParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1161,7 +1161,7 @@ func TestConnExecPreparedMaxNumberOfParams(t *testing.T) {
 func TestConnExecPreparedTooManyParams(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1198,7 +1198,7 @@ func TestConnExecPreparedTooManyParams(t *testing.T) {
 func TestConnExecPreparedCanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1230,7 +1230,7 @@ func TestConnExecPreparedCanceled(t *testing.T) {
 func TestConnExecPreparedPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1252,7 +1252,7 @@ func TestConnExecPreparedPrecanceled(t *testing.T) {
 func TestConnExecPreparedEmptySQL(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1273,7 +1273,7 @@ func TestConnExecPreparedEmptySQL(t *testing.T) {
 func TestConnExecBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1308,7 +1308,7 @@ func TestConnExecBatch(t *testing.T) {
 func TestConnExecBatchDeferredError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1345,7 +1345,7 @@ func TestConnExecBatchDeferredError(t *testing.T) {
 func TestConnExecBatchPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1380,7 +1380,7 @@ func TestConnExecBatchHuge(t *testing.T) {
 
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1411,7 +1411,7 @@ func TestConnExecBatchHuge(t *testing.T) {
 func TestConnExecBatchImplicitTransaction(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1441,7 +1441,7 @@ func TestConnExecBatchImplicitTransaction(t *testing.T) {
 func TestConnLocking(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1468,7 +1468,7 @@ func TestConnLocking(t *testing.T) {
 func TestConnOnNotice(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1502,7 +1502,7 @@ end$$;`)
 func TestConnOnNotification(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1541,7 +1541,7 @@ func TestConnOnNotification(t *testing.T) {
 func TestConnWaitForNotification(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1580,7 +1580,7 @@ func TestConnWaitForNotification(t *testing.T) {
 func TestConnWaitForNotificationPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1600,7 +1600,7 @@ func TestConnWaitForNotificationPrecanceled(t *testing.T) {
 func TestConnWaitForNotificationTimeout(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1622,7 +1622,7 @@ func TestConnWaitForNotificationTimeout(t *testing.T) {
 func TestConnCopyToSmall(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1667,7 +1667,7 @@ func TestConnCopyToSmall(t *testing.T) {
 func TestConnCopyToLarge(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1712,7 +1712,7 @@ func TestConnCopyToLarge(t *testing.T) {
 func TestConnCopyToQueryError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1732,7 +1732,7 @@ func TestConnCopyToQueryError(t *testing.T) {
 func TestConnCopyToCanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1762,7 +1762,7 @@ func TestConnCopyToCanceled(t *testing.T) {
 func TestConnCopyToPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1784,7 +1784,7 @@ func TestConnCopyToPrecanceled(t *testing.T) {
 func TestConnCopyFrom(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1827,7 +1827,7 @@ func TestConnCopyFrom(t *testing.T) {
 func TestConnCopyFromBinary(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1883,7 +1883,7 @@ func TestConnCopyFromBinary(t *testing.T) {
 func TestConnCopyFromCanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1930,7 +1930,7 @@ func TestConnCopyFromCanceled(t *testing.T) {
 func TestConnCopyFromPrecanceled(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1970,7 +1970,7 @@ func TestConnCopyFromPrecanceled(t *testing.T) {
 func TestConnCopyFromGzipReader(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2038,7 +2038,7 @@ func TestConnCopyFromGzipReader(t *testing.T) {
 func TestConnCopyFromQuerySyntaxError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2075,7 +2075,7 @@ func TestConnCopyFromQuerySyntaxError(t *testing.T) {
 func TestConnCopyFromQueryNoTableError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2096,7 +2096,7 @@ func TestConnCopyFromQueryNoTableError(t *testing.T) {
 func TestConnCopyFromNoticeResponseReceivedMidStream(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2150,7 +2150,7 @@ func (d delayedReader) Read(p []byte) (int, error) {
 
 // https://github.com/jackc/pgconn/issues/128
 func TestConnCopyFromDataWriteAfterErrorAndReturn(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	connString := os.Getenv("PGX_TEST_DATABASE")
@@ -2189,7 +2189,7 @@ func TestConnCopyFromDataWriteAfterErrorAndReturn(t *testing.T) {
 func TestConnEscapeString(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2220,7 +2220,7 @@ func TestConnEscapeString(t *testing.T) {
 func TestConnCancelRequest(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2260,7 +2260,7 @@ func TestConnCancelRequest(t *testing.T) {
 func TestConnContextCanceledCancelsRunningQueryOnServer(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2313,12 +2313,15 @@ func TestConnContextCanceledCancelsRunningQueryOnServer(t *testing.T) {
 func TestHijackAndConstruct(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	origConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
 	require.NoError(t, err)
 
+	err = origConn.SyncConn(ctx)
+	require.NoError(t, err)
+
 	hc, err := origConn.Hijack()
 	require.NoError(t, err)
 
@@ -2345,7 +2348,7 @@ func TestHijackAndConstruct(t *testing.T) {
 func TestConnCloseWhileCancellableQueryInProgress(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2366,7 +2369,7 @@ func TestConnCloseWhileCancellableQueryInProgress(t *testing.T) {
 func TestFatalErrorReceivedAfterCommandComplete(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	steps := pgmock.AcceptUnauthenticatedConnRequestSteps()
@@ -2434,7 +2437,7 @@ func TestFatalErrorReceivedAfterCommandComplete(t *testing.T) {
 func TestConnLargeResponseWhileWritingDoesNotDeadlock(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2466,7 +2469,7 @@ func TestConnLargeResponseWhileWritingDoesNotDeadlock(t *testing.T) {
 func TestConnCheckConn(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	// Intentionally using TCP connection for more predictable close behavior. (Not sure if Unix domain sockets would behave subtly different.)
@@ -2506,7 +2509,7 @@ func TestConnCheckConn(t *testing.T) {
 func TestConnPing(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	// Intentionally using TCP connection for more predictable close behavior. (Not sure if Unix domain sockets would behave subtly different.)
@@ -2547,7 +2550,7 @@ func TestConnPing(t *testing.T) {
 func TestPipelinePrepare(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2622,7 +2625,7 @@ func TestPipelinePrepare(t *testing.T) {
 func TestPipelinePrepareError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2667,7 +2670,7 @@ func TestPipelinePrepareError(t *testing.T) {
 func TestPipelinePrepareAndDeallocate(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2711,7 +2714,7 @@ func TestPipelinePrepareAndDeallocate(t *testing.T) {
 func TestPipelineQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2803,7 +2806,7 @@ func TestPipelineQuery(t *testing.T) {
 func TestPipelinePrepareQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2863,7 +2866,7 @@ func TestPipelinePrepareQuery(t *testing.T) {
 func TestPipelineQueryErrorBetweenSyncs(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -2970,7 +2973,7 @@ func TestPipelineQueryErrorBetweenSyncs(t *testing.T) {
 func TestPipelineCloseReadsUnreadResults(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -3008,7 +3011,7 @@ func TestPipelineCloseReadsUnreadResults(t *testing.T) {
 func TestPipelineCloseDetectsUnsyncedRequests(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -3040,7 +3043,7 @@ func TestPipelineCloseDetectsUnsyncedRequests(t *testing.T) {
 }
 
 func Example() {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -3152,7 +3155,7 @@ func TestSNISupport(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
 			t.Parallel()
 
-			ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+			ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 			defer cancel()
 
 			ln, err := net.Listen("tcp", "127.0.0.1:")
diff --git a/pgproto3/trace_test.go b/pgproto3/trace_test.go
index f466691f..c56a4991 100644
--- a/pgproto3/trace_test.go
+++ b/pgproto3/trace_test.go
@@ -15,7 +15,7 @@ import (
 func TestTrace(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/pgtype/example_child_records_test.go b/pgtype/example_child_records_test.go
index 9a4218ba..08d3c9e7 100644
--- a/pgtype/example_child_records_test.go
+++ b/pgtype/example_child_records_test.go
@@ -21,7 +21,7 @@ type Team struct {
 
 // This example uses a single query to return parent and child records.
 func Example_childRecords() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/pgtype/hstore_test.go b/pgtype/hstore_test.go
index ddc3de57..b16e363d 100644
--- a/pgtype/hstore_test.go
+++ b/pgtype/hstore_test.go
@@ -221,7 +221,7 @@ func TestHstoreCodec(t *testing.T) {
 	pgxtest.RunValueRoundTripTests(context.Background(), t, ctrWithoutCodec, pgxtest.AllQueryExecModes, "hstore", tests)
 
 	// scan empty and NULL: should be different in all query modes
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, pgxtest.AllQueryExecModes, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
diff --git a/pgtype/json_test.go b/pgtype/json_test.go
index f3368a41..e171104f 100644
--- a/pgtype/json_test.go
+++ b/pgtype/json_test.go
@@ -133,3 +133,29 @@ func TestJSONCodecClearExistingValueBeforeUnmarshal(t *testing.T) {
 		require.Equal(t, map[string]any{"baz": "quz"}, m)
 	})
 }
+
+type ParentIssue1681 struct {
+	Child ChildIssue1681
+}
+
+func (t *ParentIssue1681) MarshalJSON() ([]byte, error) {
+	return []byte(`{"custom":"thing"}`), nil
+}
+
+type ChildIssue1681 struct{}
+
+func (t ChildIssue1681) MarshalJSON() ([]byte, error) {
+	return []byte(`{"someVal": false}`), nil
+}
+
+// https://github.com/jackc/pgx/issues/1681
+func TestJSONCodecEncodeJSONMarshalerThatCanBeWrapped(t *testing.T) {
+	skipCockroachDB(t, "CockroachDB treats json as jsonb. This causes it to format differently than PostgreSQL.")
+
+	defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
+		var jsonStr string
+		err := conn.QueryRow(context.Background(), "select $1::json", &ParentIssue1681{}).Scan(&jsonStr)
+		require.NoError(t, err)
+		require.Equal(t, `{"custom":"thing"}`, jsonStr)
+	})
+}
diff --git a/pgtype/jsonb_test.go b/pgtype/jsonb_test.go
index dfaeb8c4..5bfbdbe3 100644
--- a/pgtype/jsonb_test.go
+++ b/pgtype/jsonb_test.go
@@ -70,3 +70,13 @@ func TestJSONBCodecUnmarshalSQLNull(t *testing.T) {
 		require.EqualError(t, err, "can't scan into dest[0]: cannot scan NULL into *int")
 	})
 }
+
+// https://github.com/jackc/pgx/issues/1681
+func TestJSONBCodecEncodeJSONMarshalerThatCanBeWrapped(t *testing.T) {
+	defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
+		var jsonStr string
+		err := conn.QueryRow(context.Background(), "select $1::jsonb", &ParentIssue1681{}).Scan(&jsonStr)
+		require.NoError(t, err)
+		require.Equal(t, `{"custom": "thing"}`, jsonStr) // Note that unlike json, jsonb reformats the JSON string.
+	})
+}
diff --git a/pgtype/pgtype_test.go b/pgtype/pgtype_test.go
index 5affc0c7..24d9e25b 100644
--- a/pgtype/pgtype_test.go
+++ b/pgtype/pgtype_test.go
@@ -47,15 +47,6 @@ type _byteSlice []byte
 // is not known (e.g. when using the simple protocol).
 const unregisteredOID = uint32(1)
 
-func mustParseCIDR(t testing.TB, s string) *net.IPNet {
-	_, ipnet, err := net.ParseCIDR(s)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	return ipnet
-}
-
 func mustParseInet(t testing.TB, s string) *net.IPNet {
 	ip, ipnet, err := net.ParseCIDR(s)
 	if err == nil {
diff --git a/pgxpool/conn_test.go b/pgxpool/conn_test.go
index b982588c..ce35c494 100644
--- a/pgxpool/conn_test.go
+++ b/pgxpool/conn_test.go
@@ -13,7 +13,7 @@ import (
 func TestConnExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -30,7 +30,7 @@ func TestConnExec(t *testing.T) {
 func TestConnQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -47,7 +47,7 @@ func TestConnQuery(t *testing.T) {
 func TestConnQueryRow(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -64,7 +64,7 @@ func TestConnQueryRow(t *testing.T) {
 func TestConnSendBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -81,7 +81,7 @@ func TestConnSendBatch(t *testing.T) {
 func TestConnCopyFrom(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/pgxpool/pool_test.go b/pgxpool/pool_test.go
index 5e529b0c..19a9986a 100644
--- a/pgxpool/pool_test.go
+++ b/pgxpool/pool_test.go
@@ -18,7 +18,7 @@ import (
 
 func TestConnect(t *testing.T) {
 	t.Parallel()
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 	connString := os.Getenv("PGX_TEST_DATABASE")
 	pool, err := pgxpool.New(ctx, connString)
@@ -29,7 +29,7 @@ func TestConnect(t *testing.T) {
 
 func TestConnectConfig(t *testing.T) {
 	t.Parallel()
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 	connString := os.Getenv("PGX_TEST_DATABASE")
 	config, err := pgxpool.ParseConfig(connString)
@@ -110,7 +110,7 @@ func TestConfigCopyCanBeUsedToConnect(t *testing.T) {
 func TestPoolAcquireAndConnRelease(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -125,7 +125,7 @@ func TestPoolAcquireAndConnRelease(t *testing.T) {
 func TestPoolAcquireAndConnHijack(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -152,7 +152,7 @@ func TestPoolAcquireAndConnHijack(t *testing.T) {
 func TestPoolAcquireChecksIdleConns(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	controllerConn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -206,7 +206,7 @@ func TestPoolAcquireChecksIdleConns(t *testing.T) {
 func TestPoolAcquireFunc(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -224,7 +224,7 @@ func TestPoolAcquireFunc(t *testing.T) {
 func TestPoolAcquireFuncReturnsFnError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -240,7 +240,7 @@ func TestPoolAcquireFuncReturnsFnError(t *testing.T) {
 func TestPoolBeforeConnect(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -264,7 +264,7 @@ func TestPoolBeforeConnect(t *testing.T) {
 func TestPoolAfterConnect(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -288,7 +288,7 @@ func TestPoolAfterConnect(t *testing.T) {
 func TestPoolBeforeAcquire(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -332,7 +332,7 @@ func TestPoolBeforeAcquire(t *testing.T) {
 func TestPoolAfterRelease(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	func() {
@@ -371,7 +371,7 @@ func TestPoolAfterRelease(t *testing.T) {
 func TestPoolBeforeClose(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	func() {
@@ -409,7 +409,7 @@ func TestPoolBeforeClose(t *testing.T) {
 func TestPoolAcquireAllIdle(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -440,7 +440,7 @@ func TestPoolAcquireAllIdle(t *testing.T) {
 func TestPoolReset(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -468,7 +468,7 @@ func TestPoolReset(t *testing.T) {
 func TestConnReleaseChecksMaxConnLifetime(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -495,7 +495,7 @@ func TestConnReleaseChecksMaxConnLifetime(t *testing.T) {
 func TestConnReleaseClosesBusyConn(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -526,7 +526,7 @@ func TestConnReleaseClosesBusyConn(t *testing.T) {
 func TestPoolBackgroundChecksMaxConnLifetime(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -553,7 +553,7 @@ func TestPoolBackgroundChecksMaxConnLifetime(t *testing.T) {
 func TestPoolBackgroundChecksMaxConnIdleTime(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -586,7 +586,7 @@ func TestPoolBackgroundChecksMaxConnIdleTime(t *testing.T) {
 }
 
 func TestPoolBackgroundChecksMinConns(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -629,7 +629,7 @@ func TestPoolBackgroundChecksMinConns(t *testing.T) {
 func TestPoolExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -642,7 +642,7 @@ func TestPoolExec(t *testing.T) {
 func TestPoolQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -674,7 +674,7 @@ func TestPoolQuery(t *testing.T) {
 func TestPoolQueryRow(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -693,7 +693,7 @@ func TestPoolQueryRow(t *testing.T) {
 func TestPoolQueryRowErrNoRows(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -708,7 +708,7 @@ func TestPoolQueryRowErrNoRows(t *testing.T) {
 func TestPoolQueryRowScanPanicReleasesConnection(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -726,7 +726,7 @@ func TestPoolQueryRowScanPanicReleasesConnection(t *testing.T) {
 func TestPoolSendBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -746,7 +746,7 @@ func TestPoolCopyFrom(t *testing.T) {
 	// different connections.
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -790,7 +790,7 @@ func TestPoolCopyFrom(t *testing.T) {
 func TestConnReleaseClosesConnInFailedTransaction(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -829,7 +829,7 @@ func TestConnReleaseClosesConnInFailedTransaction(t *testing.T) {
 func TestConnReleaseClosesConnInTransaction(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -863,7 +863,7 @@ func TestConnReleaseClosesConnInTransaction(t *testing.T) {
 func TestConnReleaseDestroysClosedConn(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -895,7 +895,7 @@ func TestConnReleaseDestroysClosedConn(t *testing.T) {
 func TestConnPoolQueryConcurrentLoad(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -921,7 +921,7 @@ func TestConnPoolQueryConcurrentLoad(t *testing.T) {
 func TestConnReleaseWhenBeginFail(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -948,7 +948,7 @@ func TestConnReleaseWhenBeginFail(t *testing.T) {
 }
 
 func TestTxBeginFuncNestedTransactionCommit(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -998,7 +998,7 @@ func TestTxBeginFuncNestedTransactionCommit(t *testing.T) {
 }
 
 func TestTxBeginFuncNestedTransactionRollback(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1045,7 +1045,7 @@ func TestTxBeginFuncNestedTransactionRollback(t *testing.T) {
 }
 
 func TestIdempotentPoolClose(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -1061,7 +1061,7 @@ func TestIdempotentPoolClose(t *testing.T) {
 func TestConnectEagerlyReachesMinPoolSize(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
@@ -1102,7 +1102,7 @@ func TestConnectEagerlyReachesMinPoolSize(t *testing.T) {
 func TestPoolSendBatchBatchCloseTwice(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/pgxpool/tx_test.go b/pgxpool/tx_test.go
index a65b30f8..e1611e67 100644
--- a/pgxpool/tx_test.go
+++ b/pgxpool/tx_test.go
@@ -13,7 +13,7 @@ import (
 func TestTxExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -30,7 +30,7 @@ func TestTxExec(t *testing.T) {
 func TestTxQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -47,7 +47,7 @@ func TestTxQuery(t *testing.T) {
 func TestTxQueryRow(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -64,7 +64,7 @@ func TestTxQueryRow(t *testing.T) {
 func TestTxSendBatch(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -81,7 +81,7 @@ func TestTxSendBatch(t *testing.T) {
 func TestTxCopyFrom(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/query_test.go b/query_test.go
index 39585a60..5ba4f2a9 100644
--- a/query_test.go
+++ b/query_test.go
@@ -193,7 +193,7 @@ func TestConnQueryValuesWhenUnableToDecode(t *testing.T) {
 func TestConnQueryValuesWithUnregisteredOID(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -220,7 +220,7 @@ func TestConnQueryValuesWithUnregisteredOID(t *testing.T) {
 func TestConnQueryArgsAndScanWithUnregisteredOID(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -1037,7 +1037,7 @@ func TestQueryRowEmptyQuery(t *testing.T) {
 	conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
 	defer closeConn(t, conn)
 
-	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	var n int32
@@ -1939,7 +1939,7 @@ func TestQueryErrorWithDisabledStatementCache(t *testing.T) {
 func TestQueryWithQueryRewriter(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -1962,7 +1962,7 @@ func TestQueryWithQueryRewriter(t *testing.T) {
 // This example uses Query without using any helpers to read the results. Normally CollectRows, ForEachRow, or another
 // helper function should be used.
 func ExampleConn_Query() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/rows_test.go b/rows_test.go
index dfa83224..b91888f7 100644
--- a/rows_test.go
+++ b/rows_test.go
@@ -56,7 +56,7 @@ func TestRowScannerErrorIsFatalToRows(t *testing.T) {
 func TestForEachRow(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -87,7 +87,7 @@ func TestForEachRow(t *testing.T) {
 func TestForEachRowScanError(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -111,7 +111,7 @@ func TestForEachRowScanError(t *testing.T) {
 func TestForEachRowAbort(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -177,7 +177,7 @@ func TestCollectRows(t *testing.T) {
 // This example uses CollectRows with a manually written collector function. In most cases RowTo, RowToAddrOf,
 // RowToStructByPos, RowToAddrOfStructByPos, or another generic function would be used.
 func ExampleCollectRows() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -287,7 +287,7 @@ func TestRowTo(t *testing.T) {
 }
 
 func ExampleRowTo() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -323,7 +323,7 @@ func TestRowToAddrOf(t *testing.T) {
 }
 
 func ExampleRowToAddrOf() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -482,7 +482,7 @@ func TestRowToStructByPosEmbeddedPointerToStruct(t *testing.T) {
 }
 
 func ExampleRowToStructByPos() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -628,7 +628,7 @@ func TestRowToStructByNameEmbeddedStruct(t *testing.T) {
 }
 
 func ExampleRowToStructByName() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
@@ -823,7 +823,7 @@ func TestRowToStructByNameLaxRowValue(t *testing.T) {
 }
 
 func ExampleRowToStructByNameLax() {
-	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go
index 9868cf31..df4a9ac1 100644
--- a/stdlib/sql_test.go
+++ b/stdlib/sql_test.go
@@ -338,7 +338,7 @@ func TestConnConcurrency(t *testing.T) {
 			go func(idx int) {
 				defer wg.Done()
 
-				ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+				ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 				defer cancel()
 
 				str := strconv.Itoa(idx)
@@ -359,7 +359,7 @@ func TestConnConcurrency(t *testing.T) {
 			go func(idx int) {
 				defer wg.Done()
 
-				ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+				ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 				defer cancel()
 
 				var id int
diff --git a/tracelog/tracelog_test.go b/tracelog/tracelog_test.go
index ab96e6e0..6812a97b 100644
--- a/tracelog/tracelog_test.go
+++ b/tracelog/tracelog_test.go
@@ -59,7 +59,7 @@ func (l *testLogger) FilterByMsg(msg string) (res []testLog) {
 func TestContextGetsPassedToLogMethod(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -89,7 +89,7 @@ func TestContextGetsPassedToLogMethod(t *testing.T) {
 func TestLoggerFunc(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	const testMsg = "foo"
@@ -127,7 +127,7 @@ func TestLoggerFunc(t *testing.T) {
 func TestLogQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -169,7 +169,7 @@ func TestLogQuery(t *testing.T) {
 func TestLogQueryArgsHandlesUTF8(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -217,7 +217,7 @@ func TestLogQueryArgsHandlesUTF8(t *testing.T) {
 func TestLogCopyFrom(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -272,7 +272,7 @@ func TestLogCopyFrom(t *testing.T) {
 func TestLogConnect(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -308,7 +308,7 @@ func TestLogConnect(t *testing.T) {
 func TestLogBatchStatementsOnExec(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -355,7 +355,7 @@ func TestLogBatchStatementsOnExec(t *testing.T) {
 func TestLogBatchStatementsOnBatchResultClose(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
@@ -394,7 +394,7 @@ func TestLogBatchStatementsOnBatchResultClose(t *testing.T) {
 func TestLogPrepare(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	logger := &testLogger{}
diff --git a/tracer_test.go b/tracer_test.go
index 409e6410..0eaf8e38 100644
--- a/tracer_test.go
+++ b/tracer_test.go
@@ -107,7 +107,7 @@ func TestTraceExec(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -147,7 +147,7 @@ func TestTraceQuery(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -189,7 +189,7 @@ func TestTraceBatchNormal(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -252,7 +252,7 @@ func TestTraceBatchClose(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -303,7 +303,7 @@ func TestTraceBatchErrorWhileReadingResults(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, []pgx.QueryExecMode{pgx.QueryExecModeSimpleProtocol}, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -372,7 +372,7 @@ func TestTraceBatchErrorWhileReadingResultsWhileClosing(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, []pgx.QueryExecMode{pgx.QueryExecModeSimpleProtocol}, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -428,11 +428,11 @@ func TestTraceCopyFrom(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
-		ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
+		ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
 		defer cancel()
 
 		traceCopyFromStartCalled := false
@@ -479,7 +479,7 @@ func TestTracePrepare(t *testing.T) {
 		return config
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, ctr, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
diff --git a/tx_test.go b/tx_test.go
index 786b7eb7..3c0ed285 100644
--- a/tx_test.go
+++ b/tx_test.go
@@ -161,7 +161,7 @@ func TestTxCommitSerializationFailure(t *testing.T) {
 	c2 := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
 	defer closeConn(t, c2)
 
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
 	defer cancel()
 
 	c1.Exec(ctx, `drop table if exists tx_serializable_sums`)
@@ -375,7 +375,7 @@ func TestBeginReadOnly(t *testing.T) {
 func TestBeginTxBeginQuery(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
diff --git a/values_test.go b/values_test.go
index 5df47f63..5369b836 100644
--- a/values_test.go
+++ b/values_test.go
@@ -19,7 +19,7 @@ import (
 func TestDateTranscode(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -61,7 +61,7 @@ func TestDateTranscode(t *testing.T) {
 func TestTimestampTzTranscode(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -84,7 +84,7 @@ func TestTimestampTzTranscode(t *testing.T) {
 func TestJSONAndJSONBTranscode(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -255,7 +255,7 @@ func mustParseCIDR(t testing.TB, s string) *net.IPNet {
 func TestInetCIDRTranscodeIPNet(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -309,7 +309,7 @@ func TestInetCIDRTranscodeIPNet(t *testing.T) {
 func TestInetCIDRTranscodeIP(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -376,7 +376,7 @@ func TestInetCIDRTranscodeIP(t *testing.T) {
 func TestInetCIDRArrayTranscodeIPNet(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -442,7 +442,7 @@ func TestInetCIDRArrayTranscodeIPNet(t *testing.T) {
 func TestInetCIDRArrayTranscodeIP(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -531,7 +531,7 @@ func TestInetCIDRArrayTranscodeIP(t *testing.T) {
 func TestInetCIDRTranscodeWithJustIP(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -580,7 +580,7 @@ func TestInetCIDRTranscodeWithJustIP(t *testing.T) {
 func TestArrayDecoding(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -699,7 +699,7 @@ func TestArrayDecoding(t *testing.T) {
 func TestEmptyArrayDecoding(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -747,7 +747,7 @@ func TestEmptyArrayDecoding(t *testing.T) {
 func TestPointerPointer(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -836,7 +836,7 @@ func TestPointerPointer(t *testing.T) {
 func TestPointerPointerNonZero(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -856,7 +856,7 @@ func TestPointerPointerNonZero(t *testing.T) {
 func TestEncodeTypeRename(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -1028,7 +1028,7 @@ func TestEncodeTypeRename(t *testing.T) {
 func TestRowsScanNilThenScanValue(t *testing.T) {
 	t.Parallel()
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 	defer cancel()
 
 	pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {