pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Will Storey <will@summercat.com>
To: pgsql-general@postgresql.org
Subject: Unexpected "canceling statement due to user request" error
Date: Fri, 16 Aug 2019 14:02:43 -0700
Message-ID: <20190816210243.tohrx52bnbxx5zra@dev.null> (raw)

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!





view thread (7+ messages)  latest in thread

Message-ID: <20190816210243.tohrx52bnbxx5zra@dev.null>
Permalink:  ../20190816210243.tohrx52bnbxx5zra@dev.null/
Also on:    postgresql.org/message-id/20190816210243.tohrx52bnbxx5zra@dev.null

 · 

reply

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: will@summercat.com
  Subject: Re: Unexpected "canceling statement due to user request" error
  In-Reply-To: <20190816210243.tohrx52bnbxx5zra@dev.null>
  References: <20190816210243.tohrx52bnbxx5zra@dev.null>

* 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