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 1hz3Cx-0004CP-J3 for pgsql-general@arkaria.postgresql.org; Sat, 17 Aug 2019 18:13:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hz3Cw-0003VR-Fb for pgsql-general@arkaria.postgresql.org; Sat, 17 Aug 2019 18:13:42 +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 1hz3Cw-0003Tq-5U for pgsql-general@lists.postgresql.org; Sat, 17 Aug 2019 18:13:42 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hz3Cu-00010E-Fy for pgsql-general@postgresql.org; Sat, 17 Aug 2019 18:13:41 +0000 Received: by mail-pg1-x535.google.com with SMTP id l21so4568733pgm.3 for ; Sat, 17 Aug 2019 11:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UgjvwIAOEl/LTZltY0UwweOvlWwDuKvfCJxsJYNs118=; b=iQ9+yhUQC1FgO89BWHZ+W720tT3EmPNZFIIY9aWW8GlGkc1E9N9FWDT4BkWRfi3pCn 1wdhI8BTCLNe8pPS4inabt5UscuJ3/RrWc9HN6nAdrniTw5qnYtYbf6tNHfci/dfUtSt bkKEZXCJJGWWg2UguvjZAOxCvawooOlTiC/NzKMcYG4ruuZ032tkRIiwsj66ZFg/R27g QEqVEEf7pm/LIVrH7CJIxIdzXf51xMy6aTcVYX0wOdWhnXsiQR79nmzbP1sfgHMh23Ni 3BqSdtcCoGlhjQOdqaUZw8Z9ySBHEO2R2Zs8dXkQDWkkblxJ8lr7pPcVJzdiztvfy0Cr 1Lpw== 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:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=UgjvwIAOEl/LTZltY0UwweOvlWwDuKvfCJxsJYNs118=; b=AJo2ePLrvgqjfmd63Ee+i5CbrU2Iys0qKufbnB3vubneHL1QaqjZkWj54Z9Rp8DtaW aSnfoAZ6TfeVBKz+a/NGuEWlPeEH4GgYZ2h37vGbvOZFRjRZO2PIdl/kCks6HjDurFMS 4q/7kBHnAEnIqrTzZR7pJLpNKaxDfvFz8q58kSX4g09mT/Lk7o5WS/L+i8kwL4MWMVg4 n+RSg93Gkjfd9R0N+cGbTy6axHnpyWtunC7+aB98K8oxNn07TJSMtrnm42WVxy5Pez2E nSl1iad57jTI7URxzzJlEG6s8gzDLQB5/AOd7B19ZczMz7Tav2LPmCBXWeqktXo/uE1n Z1Mg== X-Gm-Message-State: APjAAAVplVvXMbIU8DjenX8s2aCNSyYz7lzjNH5ZeKed9EhMwV0I00W8 dTHF5LlJNukJAbwzi/9Zhco= X-Google-Smtp-Source: APXvYqypXLqZxcdUBVsh8FdHuHTFgeqYnuUik9dMk/NGJZt0aIPQFczYul+c0HwS3hvLQv9T5TS19Q== X-Received: by 2002:a17:90a:7d04:: with SMTP id g4mr13167611pjl.41.1566065618283; Sat, 17 Aug 2019 11:13:38 -0700 (PDT) Received: from dev.null (d64-180-144-158.bchsia.telus.net. [64.180.144.158]) by smtp.gmail.com with ESMTPSA id r13sm13209834pfr.25.2019.08.17.11.13.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Aug 2019 11:13:37 -0700 (PDT) Sender: Will Storey Date: Sat, 17 Aug 2019 11:13:35 -0700 From: Will Storey To: Adrian Klaver Cc: pgsql-general@postgresql.org Subject: Re: Unexpected "canceling statement due to user request" error Message-ID: <20190817181335.wc7t3z3tfs7taiqo@dev.null> References: <20190816210243.tohrx52bnbxx5zra@dev.null> <34a5ea6d-8dbb-e46a-0c08-fbbea4d4bcd7@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <34a5ea6d-8dbb-e46a-0c08-fbbea4d4bcd7@aklaver.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat 2019-08-17 10:32:40 -0700, Adrian Klaver wrote: > > 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. Thanks for the pointer! It looks like we'd have to be entering that section and finding the statement timeout not set, otherwise we'd not fall through to the "user request" case. But as far as I can tell, the only reason my query would be cancelled is because of the statement timeout. I wonder if there is some way the statement timeout flag is being lost/cleared. I see there's situations where we clear timeout flags. Something I forgot to mention: The queries are against a hot standby server.