On 8/16/19 2:02 PM, Will Storey wrote:
Hi! I have a query that fails due to this error and I'm trying to understand why. My understanding is I should only see this error if I cancel a query manually, such as with kill -INT or with pg_cancel_backend(). However I can't find anything doing that. The query looks like this: SELECT * FROM ( SELECT c1, c2, [...], EXTRACT(EPOCH FROM time) AS epoch, to_rfc3339_us(time) AS time_rfc3339 FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE c2 = ?) AND c2 = ? AND time < ? AND time > ?::timestamptz - ? * interval '1 day' LIMIT ? ) AS s ORDER BY epoch DESC t1 is partitioned on time, by month. I run it using Perl's DBI with DBD::Pg. I wrap it in a transaction where I first run: SET LOCAL statement_timeout TO 1000 I know this query can time out, and it does, resulting in the error I expect: "canceling statement due to statement timeout". The problem is occasionally I see this other error: "canceling statement due to user request". Looking at the query logs, when the query fails with the user request error, the query reached the statement timeout (at least in cases I checked). In one instance the duration shows as 1283ms for example. Could there be any situation where a query getting cancelled due to a statement timeout be reported as cancelled due to user request? Or do you have any ideas about what might be going on?
Here is the relevant source: https://doxygen.postgresql.org/postgres_8c.html#ab7af3ee6ad40efb8454c6f2f790d9588 Start at around line 3078.
This is on PostgreSQL 9.6.14 on Ubuntu Xenial. Thank you!
-- Adrian Klaver adrian.klaver@xxxxxxxxxxx