Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBWWx-00HCbH-WA for pgsql-general@arkaria.postgresql.org; Mon, 27 May 2024 09:20:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sBWWx-005yG3-DV for pgsql-general@arkaria.postgresql.org; Mon, 27 May 2024 09:20:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBWWw-005yFu-Uc for pgsql-general@lists.postgresql.org; Mon, 27 May 2024 09:20:35 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sBWWt-002CQ6-Pd for pgsql-general@lists.postgresql.org; Mon, 27 May 2024 09:20:33 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5785fc9c543so2982060a12.1 for ; Mon, 27 May 2024 02:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1716801630; x=1717406430; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=Gj8ZuT8HiczCIWLAmsTXuiRYlDdkEY9KEI7knWqQhDA=; b=BWbpF8NjpQXeHr5jyWv92E1eJnzu9dGLw7Nz8QRucJC+131RZsW1BOUYmBSNCoIhfp kfC9BV3Q+L4zW+B0QOAkTJmpxF3odkCrakx9EhFqMKZWrCl2++EkqPGjbhmE3agJ0IBu r6XUjnFEidBcJU2YSJ7pAGNS/uSR6RH5jD66jEcBMsJxDz7h8KjdyXWegG4FpHOPK6zV Robvu8U7ffJGOCVDh9zqX6lIZcROGAoZXVds0De1R0w4Cy607Avbc8c962PDhc5YTxnS okq4tEKC8qYKS7q2FQiRo53raOl3BO9aJI/JLroUmnBZPRC94FzR0o8dWvJOvtmfVXwX +obg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716801630; x=1717406430; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gj8ZuT8HiczCIWLAmsTXuiRYlDdkEY9KEI7knWqQhDA=; b=SeZCeHIEjNjLG+aYNpUdRjfL7mmYL1Y4P9FNVJXiVyvM8lIRjIQ5ica5EU08Zh2DOq bcNVJL+7IWF3/0eGwy1TVUXeofNZhbekodC7E/ma1zfoRisG5Isl1pRr9nViX2VC86Ri cVjoR/8HfidVA9/6ud5MHrTCxkOohT5lSAab6bLk1hcP+aFY4ZhkdkLVD04BCUWqawDd 3IndE/xyhU6+ckV5mpIvR9bfqX6IVTeaInlrUkjxADSsssjh8cO+VLeloEiEZeQ1aPZU ZLtOpYrmauv5QRDG91Oo7mk91TLAS3UUhzzwmQDs5V2nkX7+HqlmVtWiHvrMlrZbGrWi aFng== X-Gm-Message-State: AOJu0YzPzxrbJL4z4ivq0w1UDH3hxzyIs8NG7U1HjrQhi2rjGMPx65Qx oSyCr6/ME2Efrl/8iQ19Qg1tCubhbiuGX6pue2nVB0Q7wY11qiGRlJXq4UJVJK8= X-Google-Smtp-Source: AGHT+IFp5NRx4A5gwU71qcQuRx7OhL/hPI1hiGhkwl3YuZBf5vF38X9cJJwP6EyANyfCXjHQz8igJw== X-Received: by 2002:a50:c2d2:0:b0:578:42fb:a4d with SMTP id 4fb4d7f45d1cf-578519aa3ffmr8697754a12.30.1716801630183; Mon, 27 May 2024 02:20:30 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:1ee1:2933:8762:af5c:a0fe]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578524bb79esm5500523a12.92.2024.05.27.02.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 02:20:29 -0700 (PDT) Message-ID: Subject: Re: Long running query causing XID limit breach From: Laurenz Albe To: yudhi s , sud Cc: pgsql-general Date: Mon, 27 May 2024 11:20:29 +0200 In-Reply-To: References: <891bcfec74f7358ef0212caf6565a35153dd2941.camel@cybertec.at> Autocrypt: addr=laurenz.albe@cybertec.at; prefer-encrypt=mutual; keydata=mQINBGGDwAQBEADgbWy5cKXQld3N2mF+DFyiNFbi2oBl2T+XgxpPF8wTRw2D/u4bBKXP0SYSE/lA86jIVNWWU0gf1KODIkVvgJm2w4vH2VBV1b7ddVViGl1Iu+9zaRnv9wulhnH42KefepXnoean6UT1EzLM0opF/Ik0j+40TxdRtobkBprkQUyHDXWlHc2ffPs3SipyFEP9AVLf7ejRC46CXWDnsqjOBSMEW8Z4HiK/8RrPZBsKLts8dJxKF4pygOdJb0CWk8k/X1jbcfdxo+zOLjOMvJcSJ2pFdJmQHU+JufB3rePziqQ2S9Ur6sccr9XnTC1GVBWN4Lf5VHq+vf+bFJjVwg+2hrySZnAVfcOrxoqFLErr7ug1zN2nM1kcpgA4VWn4gxlJtYNYYq+9WxX5dtvnNANlG3ZCrRKQzl8lxtzoF6Zo7LUhEqPaHDwn7Rvs+IdbOn41lF5UDTJGqmC4gS/bZydW2Fy3YWm4aSaN9fgFf8D+PVkrlKAZB7gBLz1TyHjbcRf85cYF+GKKrDld5SzMB/V60VX3oP/Eo8ikFpyWaqiz1f9X7MBot3/PjJkY+wDzp3nmb19QEcOBuQiSQ4xds2r0HewbuHTAR68u8jNNMGmpm2j4x+g09Jd/WQDjqlTBZ/jEltH41fYCCPWMfljXTOOXu2e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gG4Gmh6aviDTJhfXtH4rPUNXhDLqrTH8JkJjyKROOMakIF68Hjse5vUfUxreBEOtb5r1Coa2Fe7ncJayaSE7ryrDbFqpZ 36UMAx4ulWMyqJajLNGY0DdG8qIsR5nxRhrnK/mrCidZ8F9/D3bWAl4rjtHlsztN59 +AnW5l0HsQcY9ntFL/zEBOaonjdJf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Fri, May 24, 2024 at 10:34=E2=80=AFAM sud wrote: > > I am trying to understand these two parameters and each time it looks a= bit confusing to me. > > If These two parameters complement or conflict with each other. > >=20 > > Say for example, If we set hot_feedback_standby to ON (which is current= ly set as > > default ON by the way), it will make the primary wait till the query co= mpletion at > > standby and can cause such a high bump in XID in scenarios where the qu= ery on standby > > runs for days(like in our current scenario which happens). So we were t= hinking of > > setting it as OFF,=C2=A0to avoid the=C2=A0transaction ID wrap around is= sue.. "hot_standby_feedback" is not "on" by default; you must have changed it. This parameter will not make anything wait. The effect is that VACUUM on t= he primary server won't remove any old row versions that are still needed by a query on the standby. This holds back the "xmin" horizon and can lead to bloat and, if you consume transaction IDs quickly, to wraparound problems. > > But as you also mentioned to set the "max_standby_streaming_delay" to -= 1 (which is > > currently set as 14 second=C2=A0in our case) ,it will wait infinitely ,= till the query > > completes=C2=A0on the standby and wont apply the WAL which can cause ov= erride of the XID > > which the standby query is reading from. But wont this same behaviour b= e happening > > while we have hot_feedback_standby set as "ON"? "It" is the standby, where you set the parameter. The primary is not affec= ted by that at all. If there is a replication conflict on the standby, replay of the W= AL information is delayed until the query is done. There is no conflict between these settings; they do something different. > > But again for HA , in case primary down we should not be in big lag for= the standby > > and thus we want the standby also with minimal lag. And as you mentione= d there will > > never be incorrect results but at amx it will be query cancellation, so= I was thinking, > > if it's=C2=A0fine to just keep the "hot_feedback_standby" as OFF and le= t the > > max_standby_streaming_delay set as it is like 14 sec. Let me know your = thoughts. >=20 You cannot have it. Let me repeat: you cannot have it. The only way you can have no delay in replication AND no canceled queries i= s if you use two different standby servers with different settings for "max_standby_streaming_delay". One of the server is for HA, the other for your long-running queries. Yours, Laurenz Albe