-
-
Notifications
You must be signed in to change notification settings - Fork 972
Description
The Cloud SQL Go Connector works with pgx by providing an implementation of pgconn.DialFunc that creates a TLS 1.3 connection in a seamless way for callers.
The connector wraps the resulting TLS connection in part to support a MySQL health check by adding an implementation of syscall.SyscallConn. The full details are here, but in short, the MySQL driver uses syscall.SyscallConn to do a zero byte read to ensure the connection is alive, and otherwise knows to recycle it. Even though the Go standard library advises that reading and writing to the underlying connection will corrupt the TLS session, this works because no reads or writes are actually performed.
Meanwhile, in the pgx v5, there is now a new NetConn type that uses the syscall.SyscallConn interface to perform non-blocking reads and writes.
When I try to upgrade the Go Connector to pgx v5, though, the reads and writes hang indefinitely, presumably because pgx is trying to use the syscall.SyscallConn interface which otherwise does not work given the connection is actually encrypted.
The options for fixing this in the Go Connector seem to be:
- Drop support for the MySQL health check
- Don't use pgx v5
- Have pgx add a configuration value for opting out of the non-blocking reads and writes
None of the above are ideal. Are there any other options here?