Pgx: Is pgx vulnerable to any of the go-mysql-driver issues?

Created on 22 May 2020  路  2Comments  路  Source: jackc/pgx

Hi!

By now I'm sure you've seen https://github.blog/2020-05-20-three-bugs-in-the-go-mysql-driver/, and it struck me as interesting to investigate whether pgx suffers from any issues around this as well. I assume with the postgres protocol being different from the mysql protocol that the TCP close issues are not an issue specifically, but both the timeout and race issues could potentially affect pgx as well.

What do you think?

Most helpful comment

Regarding lost connections:

I agree with some of the dissent on the original MySQL issue https://github.com/go-sql-driver/mysql/issues/657 where it was argued that the real solution is to have the clients have a shorter timeout than the server so there are not routinely being killed. There is an open issue for how to handle lost database connections more gracefully: #672. But perspective is more how to handle database restarts and network interruptions than trying to work around _interesting_ server timeout settings.

Regarding context cancellation during connection, pgx should respect context through the entire connection process.

And as far as the race condition on context cancellation during a a query, pgx is not susceptible for two reasons.

  1. pgx doesn't reuse main driver buffer memory.
  2. Recovering a connection that has had a query interrupted by a context cancellation is sometimes impossible and is very tricky to do correctly even when it is possible. So pgx treats context cancellation is most places as a fatal error -- a connection is never reused after a normal query is started and interrupted.

All 2 comments

Regarding lost connections:

I agree with some of the dissent on the original MySQL issue https://github.com/go-sql-driver/mysql/issues/657 where it was argued that the real solution is to have the clients have a shorter timeout than the server so there are not routinely being killed. There is an open issue for how to handle lost database connections more gracefully: #672. But perspective is more how to handle database restarts and network interruptions than trying to work around _interesting_ server timeout settings.

Regarding context cancellation during connection, pgx should respect context through the entire connection process.

And as far as the race condition on context cancellation during a a query, pgx is not susceptible for two reasons.

  1. pgx doesn't reuse main driver buffer memory.
  2. Recovering a connection that has had a query interrupted by a context cancellation is sometimes impossible and is very tricky to do correctly even when it is possible. So pgx treats context cancellation is most places as a fatal error -- a connection is never reused after a normal query is started and interrupted.

Thanks for the detailed analysis!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nick-jones picture nick-jones  路  4Comments

pengux picture pengux  路  3Comments

bernhardreiter picture bernhardreiter  路  7Comments

zargex picture zargex  路  8Comments

badoet picture badoet  路  10Comments