Golang pgconn.errTimeout context canceled

Suppose you just received the following error:

*pgconn.errTimeout: timeout: context canceled

during database operation attempts in your Go app.

Obviously, the first thing you need to check is your query, its performance, and timeout values. You might miss some index creations, etc.

If everything is ok with your query and it’s working well and constantly faster than that timeout value, the reason may be another transaction. Simply put, something or somebody might start the transaction and neglect to commit (or rollback) it.

In my case, I figured out that the DB browser IntelliJ IDEA Plugin automatically started a new transaction and required a manual commit. All the time it was hanging, the Go’s pgconn driver gave timeout errors.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *