From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Will Storey <will@summercat.com>
To: pgsql-general@postgresql.org
Subject: Re: Unexpected "canceling statement due to user request" error
Date: Sat, 17 Aug 2019 10:32:40 -0700
Message-ID: <34a5ea6d-8dbb-e46a-0c08-fbbea4d4bcd7@aklaver.com> (raw)
In-Reply-To: <20190816210243.tohrx52bnbxx5zra@dev.null>
References: <20190816210243.tohrx52bnbxx5zra@dev.null>
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@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, will@summercat.com
Subject: Re: Unexpected "canceling statement due to user request" error
In-Reply-To: <34a5ea6d-8dbb-e46a-0c08-fbbea4d4bcd7@aklaver.com>
References: <20190816210243.tohrx52bnbxx5zra@dev.null> <34a5ea6d-8dbb-e46a-0c08-fbbea4d4bcd7@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox