Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyjN8-0001q0-FL for pgsql-general@arkaria.postgresql.org; Fri, 16 Aug 2019 21:02:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hyjN5-0002Tg-Fl for pgsql-general@arkaria.postgresql.org; Fri, 16 Aug 2019 21:02:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyjN5-0002TZ-3R for pgsql-general@lists.postgresql.org; Fri, 16 Aug 2019 21:02:51 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyjN2-00061z-Gz for pgsql-general@postgresql.org; Fri, 16 Aug 2019 21:02:50 +0000 Received: by mail-pf1-x436.google.com with SMTP id 129so3722981pfa.4 for ; Fri, 16 Aug 2019 14:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition; bh=6lIDqQW6UmhW4GpuEQIDfbKAp1MpZeSP2MPjpfYcmec=; b=ju4pmolKrUDWV6OkhE2ooRtDqBGPszSOUpQkPIGow92CfR7P4hWT6rnEdTN1SoCKqp LEz18rH9FjDuJUCO32N+NxQkkG7CF54IyLGZ7aPORtp2OyiGrp6QQ+joQaB6QRxrV5+8 ZqExIXXjYEau+zOqOdcX2jUrzV0V7MwLPDFVSSnG9UzjIoVSVBG88m09H+66cECDmtda nKAv6xiiviDlY47W6G5t4i+S2e2fUwUu+NeowP7eJQRS0U3RnqsAkRibeHb7KcMbUc8h cJ9Th1PKRgWv8cUSAiOKfOl3PW8xa5Fh+LelXdw1NRVP8iQhO5ep1eNcxRGXf4zpFtzJ 0FAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :mime-version:content-disposition; bh=6lIDqQW6UmhW4GpuEQIDfbKAp1MpZeSP2MPjpfYcmec=; b=QjzFKnyg1lFvzLk9bv1wCIwgcVAXgvOur3+3g30JvCY89EIr0MYQsnC1Ax5sgmK9In i3a9oq2713FW4cjs+UViBaz2+HOtnIy2PX+cOlD+sAITzTZPqA7Zsl3+v74lS3fbQvZD A9fHJ50kTCPRc0o+r+ctNjNvz/CaaY98mojX5jz+9w76sFm4CHydwoO6zEiLDeNWhBL3 rsAhbOSWqGmqLeCLC5CrgNYPmI2DwQxm/vycUHHw0mbBxOV+18kN8gcNVfaYt+AW1O/u 7uA88n23R1hfHPUNtG9uq37R2Vqql8XfDWLhyffwo8+5JXTQXp6RGYmUkbkzWsXJFLIg KSrQ== X-Gm-Message-State: APjAAAW777kYd+YjdxVTKFXbc/LcowqRoHYAu2ycFEomHmAiduJjCmbQ m8LWeB9t6KewEmq852qc8oXbbMUo X-Google-Smtp-Source: APXvYqyN//Kfl5jBxqawtq3cs0k3E/jCWrmZljreSqdcrIRa2EYWciGVDdDTx+z92G452yo5vBHEaA== X-Received: by 2002:a63:4823:: with SMTP id v35mr9398768pga.138.1565989365824; Fri, 16 Aug 2019 14:02:45 -0700 (PDT) Received: from dev.null (d64-180-144-158.bchsia.telus.net. [64.180.144.158]) by smtp.gmail.com with ESMTPSA id s5sm3281723pjo.26.2019.08.16.14.02.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Aug 2019 14:02:45 -0700 (PDT) Sender: Will Storey Date: Fri, 16 Aug 2019 14:02:43 -0700 From: Will Storey To: pgsql-general@postgresql.org Subject: Unexpected "canceling statement due to user request" error Message-ID: <20190816210243.tohrx52bnbxx5zra@dev.null> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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!