Gordon Seidoh Worley
Gordon Seidoh Worley

Reputation: 8088

Postgres queries running longer than statement_timeout

I have statement_timeout set to 10000 (10 seconds) for a user in my Postgres database. However when I look at active queries in pg_stat_activity I find queries running for over 10 seconds (in some cases longer than 10 minutes). I set statement_timeout on the role executing these queries, and I have verified that in the pg_user table the user has statement_timeout=10000 set.

These statements are all inserts and I've verified there are no ungranted locks.

Why are these queries not being killed after the timeout?

Upvotes: 2

Views: 2659

Answers (1)

Gordon Seidoh Worley
Gordon Seidoh Worley

Reputation: 8088

It appears the issue is that the transactions are in the idle state (and since this is Postgres 10 I can further tell you the wait_event is ClientRead) and this means they are governed by a different timeout (although the documentation is ambiguous about this). The relevant config to set is idle_in_transaction_session_timeout.

Upvotes: 6

Related Questions