Unexpected "canceling statement due to user request" error - Mailing list pgsql-general

From Will Storey
Subject Unexpected "canceling statement due to user request" error
Date
Msg-id 20190816210243.tohrx52bnbxx5zra@dev.null
Whole thread Raw
Responses Re: Unexpected "canceling statement due to user request" error
List pgsql-general
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?

This is on PostgreSQL 9.6.14 on Ubuntu Xenial.

Thank you!



pgsql-general by date:

Previous
From: Susan Hurst
Date:
Subject: Re: Missing Trigger after pgdump install
Next
From: Adrian Klaver
Date:
Subject: Re: Missing Trigger after pgdump install