lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.01k stars 910 forks source link

Bad connection error after commit fails due to statement_timeout #925

Open horgh opened 4 years ago

horgh commented 4 years ago

Hello!

I have been periodically seeing these errors in my application:

driver: bad connection

I investigated today and I found strange behaviour in this situation:

I'm wondering if this is what should be happening given there is an error message available showing that the transaction failed.

Here is a program that demonstrates this: https://play.golang.org/p/fYi3vNb3p7L

If you run this for a while (e.g. while [ true ]; do ./foo ; done), you will periodically see messages like this:

error committing: pq: canceling statement due to statement timeout
error pinging after commit failure: driver: bad connection

I am using lib/pq v1.2.0, Postgres 9.6.15, and Go 1.13.4.

What do you think?

Thank you!