Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fEfRn-00040Z-9O for pgsql-general@arkaria.postgresql.org; Fri, 04 May 2018 18:28:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fEfRk-0003L4-TN for pgsql-general@arkaria.postgresql.org; Fri, 04 May 2018 18:28:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fEfRj-0003Ku-Ey for pgsql-general@lists.postgresql.org; Fri, 04 May 2018 18:28:44 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fEfRe-0007nM-Bl for pgsql-general@postgresql.org; Fri, 04 May 2018 18:28:42 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 3F05721AE4; Fri, 4 May 2018 14:28:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 04 May 2018 14:28:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=oHAddBqp+MZAf7KKf/XWefYs3rzLU xJxIqdt8hqdfao=; b=U0iZeNlsU9Vs27mbxvWuJai68w2JQ1yMr7kOlDpnYKeqa 62Woxz5hC16ILTgasQr06S0iOgofgQxwznBaxLnEoiFYHlqU2Jz2jW2ykycMSkGP Zw4bK1srh6b7K11MvbG8oXRDsvOcYfbM4ncH5RHJD7SOvuKX3wpZSeuyvYNmfPBH NzIAd/NU4rfUdNPjU5GhpI6Ibw/AKso2DAol9yxGVzRQQV1tMiuAF4s6fAde+cve fCXqKEBZLribRH4Phxqy3CdeEUKe3Oo2AQzHe4zSD1meEYmRRuSnjezJwmAPYuWY SJd0qb0GL5dMJimf7wrdIAkOk0ckl1rL0KrXNGOwA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=oHAddB qp+MZAf7KKf/XWefYs3rzLUxJxIqdt8hqdfao=; b=Lg93XZTj069xzxHulWvA+E OSNRLZb3s0l1LyMw5miwvJF40w0tcX3w0cTmV15ALVMa+aqRjcLbC6j0Aqhq/BWk vB/C8GyndrNS7x5UgOLvswkib4g+1eq9sw0JwsuZppEXr+rFR5wpsvaq3aNGatZz 2SGVdbl4SxJjCn+Q5ommWTFbVMHedUtXGIlW9sM5smsmy5KBzkY5V5SgocJPsfLJ 4fvyVvFiVlX2Po94qWLBOOaA4K7XUlLgTGjSlC1UExrQrEKbL0I0QYI1hjR6fNf/ mcboO01KQIz38ah/AC3Late0BO77hy+iuadtcpf2XFrW7yA0+7BrQqeY1MBQedaw == X-ME-Sender: Received: from [192.168.1.2] (unknown [71.212.135.74]) by mail.messagingengine.com (Postfix) with ESMTPA id A5CF610263; Fri, 4 May 2018 14:28:36 -0400 (EDT) Subject: Re: statement_timeout issue To: harding.ian@gmail.com, General PostgreSQL List References: From: Adrian Klaver Message-ID: <1841c2b1-78f2-27f2-8e20-9c7b39a85e11@aklaver.com> Date: Fri, 4 May 2018 11:28:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/04/2018 09:52 AM, Ian Harding wrote: > I know there are a lot of moving parts to this issue but I think I've > eliminated most of them and the problem comes down to the postgresql > server generating a statement_timeout error after 10 seconds when the > connection statement_timeout is actually set to 15 minutes. > > My web server gets a database handle which it keeps for the duration of > the function that generates the response.  Multiple queries can be sent > and will use the same handle. > > After getting the handle I issue "show statement_timeout" and log the > result which shows 15 minutes. > > 84876:May  4 08:31:06 seattle-vm-1-0 nsd: STATEMENT_TIMEOUT IS: > 84877-May  4 08:31:06 seattle-vm-1-0 nsd: statement_timeout = 15min > > Then I send a query, and it generates a statement_timeout error after 10 > seconds. To follow up on Andres's suggestion, when you do the above do: select * from pg_settings where name = 'statement_timeout'; and see what the source field is pointing to. > > The log has a CONTEXT which indicates a foreign key lookup was going on > at the time which is fine... > > 2018-05-04 04:05:20 PDT [62028]: [82-1] ERROR:  canceling statement due > to statement timeout > 2018-05-04 04:05:20 PDT [62028]: [83-1] CONTEXT:  SQL statement "SELECT > 1 FROM ONLY "public"."clients" x WHERE "c_id" OPERATOR(pg_catalog.=) $1 > FOR KEY SHARE OF x" > 2018-05-04 04:05:20 PDT [62028]: [84-1] STATEMENT:  INSERT /* > > Is there anything I'm not thinking of? > > Thanks! > > - Ian -- Adrian Klaver adrian.klaver@aklaver.com