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 1sEk5j-003LXv-SN for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2024 06:25:49 +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 1sEk5j-005c36-Vb for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2024 06:25:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sEk5j-005c2x-JA for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2024 06:25:47 +0000 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sEk5h-0004ft-Cq for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2024 06:25:47 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-4eb2b07f660so633421e0c.0 for ; Tue, 04 Jun 2024 23:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717568744; x=1718173544; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SyXFosuAwBgwnYWNwEcNKug1A9XWloJ/9PTnCMryrjc=; b=BCPvjPNUodH00+5o7PSZj1ni66qlvaXgzaGdVAl+FpgIXnFtNV8NBjQT2JymnhV5Sb aGT9eyzWRRQ5kaU/p986KQHYF40rqnQQhPDujVRyId25iy2JqMcwwnXvMcjik+5wbxD3 Vuk5th6XPkuqNW+LedYXqVAIkcHHK1mGnNu47jDEBu/YgxDBLsqoIzJfO8rwpvC1z0AQ vStitA9rMq5fwRpbe1ruP7+YEM6NR+quYYfcsqEYtGRxocSv8PMUGk/PcFcTp6H6GNIy 83i4UeUpmrEnRJacX6usjpl9G+5pfOtAD5T1wfecaQcHoAQIMNViWoDMd1lizknYvaez vptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717568744; x=1718173544; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SyXFosuAwBgwnYWNwEcNKug1A9XWloJ/9PTnCMryrjc=; b=nBeYg+3Bkh2RqjIuitJqXKRzLg/UBk1rrXkfphtQxdEeaK2dv18rz8lPV0u2efdKbO nsmm/pq+wGlSaJXNC9RkScuCJTe+Bn/5nNy26HyX/A9LIxibufY3AeZUBjkpC6gRPy7i p0Vh71N0MDndxifAQsiAqFd9sjKpCofoMRmNGBwuIwtRclrNaekc543M8hzWbXTkO+mp L1mPF8eB/RuCfOc+xXx0Jz8/0whWsz80HrdvMEYFtMcNGuQb69JfufAhKnb2VVZfntiG VcYN+nn+WIzAZuusmOtbFF8WWxwrzuBRGKso1SYOyBmP4aXu9+hhdM4j3Nvd94o+aSN7 UZmA== X-Forwarded-Encrypted: i=1; AJvYcCWnpCGCumFLMQzNyhExpTq77+0ZNCzgmBi9Sn/YMomOFCKZRxR43I6lJvXTc/6GsCs+lkEChvIl30TbHc3HM55jcWlPSKSKvl3h1YY28bdMcXqB X-Gm-Message-State: AOJu0YzwBq0D1oEbi2gKAXqRQRZuvWzWfxJcIvY4mdUKu3BH7LxE2MKK 4PzKDO81lrlg+azHcVOlP97ElQStHvy4AIdybgnEtaF2I61TTFHndPQBF7HNkKR/4/SkD7sZQVI +O4/kYe85D2Sxkr07a4LKJHj2TK4= X-Google-Smtp-Source: AGHT+IHQzZWT7XDvslTsmXqo/ohWXFlJ0u2z30hfNvAfMILfE/L8GkHt6UoiT7I9yVMDZSkklVjig8zyxFnPlwyCwMU= X-Received: by 2002:a05:6122:3691:b0:4e4:e9db:6b22 with SMTP id 71dfb90a1353d-4eb3a3c5d13mr2400563e0c.3.1717568743978; Tue, 04 Jun 2024 23:25:43 -0700 (PDT) MIME-Version: 1.0 References: <891bcfec74f7358ef0212caf6565a35153dd2941.camel@cybertec.at> <56ad97911d83f721dd872e8ee68cd77d50d3eef6.camel@cybertec.at> In-Reply-To: <56ad97911d83f721dd872e8ee68cd77d50d3eef6.camel@cybertec.at> From: sud Date: Wed, 5 Jun 2024 11:55:32 +0530 Message-ID: Subject: Re: Long running query causing XID limit breach To: Laurenz Albe Cc: yudhi s , pgsql-general Content-Type: multipart/alternative; boundary="000000000000dcbfcb061a1ea298" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dcbfcb061a1ea298 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Laurenz, Thank you so much.This information was really helpful for us understanding the working of these parameters. One follow up question i have , as we are setting one of the standby/replica with value idle_in_transaction_session_timeout=3D-1 which c= an cause the WAL's to be heavily backlogged in a scenario where we have a query running for very long time on that instance. So in that case will there be chances of instance restart and if that can be avoided anyway? And the plan is to set these system parameters with different values in writer/read replica , so in that case if we apply the "alter system" command on the primary , won't the WAL going to apply those same commands forcibly on reader instance making those same as the writer instance configuration( but we want the reader replica configuration to be different from writer)? Appreciate your guidance. On Wed, May 29, 2024 at 1:38=E2=80=AFPM Laurenz Albe wrote: > On Wed, 2024-05-29 at 01:34 +0530, yudhi s wrote: > > > The only way you can have no delay in replication AND no canceled > queries is > > > if you use two different standby servers with different settings for > > > "max_standby_streaming_delay". One of the server is for HA, the othe= r > for > > > your long-running queries. > > > > When you suggest having different max_standby_streaming_delay for first > replica > > (say 10 sec for High availability) and second replica(say -1 for long > running queries). > > Do you also suggest keeping "hot_feedback_standby" as "OFF" for all th= e > three > > instances i.e. master and both the replicas? > > The parameter is ignored on the master. > It needs to be off on the standby that is running long queries. > For the other standby it probably doesn't matter if you are not running a= ny > queries on it. I would leave "hot_standby_feedback =3D off" there as wel= l. > > Actually, I would set "hot_standby =3D off" on the standby that is only u= sed > for HA. > > > - I would leave "hot_standby_feedback" off everywhere. > - "max_standby_streaming_delay" should be -1 on the reporting standby and > very > low or 0 on the HA standby. It doesn't matter on the primary. > - "statement_timeout" should be way lower on the first two nodes. > - "idle_in_transaction_session_timeout" is good. > - I would leave "autovacuum_freeze_max_age" at the default setting but 10= 0 > million > is ok too. > > Yours, > Laurenz Albe > --000000000000dcbfcb061a1ea298 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Laurenz,

Thank you so = much.This information was really helpful=C2=A0for us understanding=C2=A0the= working of these parameters.

One follow up questi= on i have , as we are setting one of the standby/replica with value idle_in= _transaction_session_timeout=3D-1 which can cause=C2=A0the WAL's to be = heavily backlogged in a scenario=C2=A0where we have a query running for ver= y long time on that instance. So in that case will there be chances of inst= ance restart and if that can be avoided anyway?

An= d the plan is to set these system=C2=A0parameters=C2=A0with different value= s in writer/read replica , so in that case if we apply the "alter syst= em" command on the primary , won't the WAL=C2=A0going to apply tho= se same commands forcibly on reader instance making those same as the write= r instance configuration( but we want the=C2=A0reader replica configuration= to be different from writer)?=C2=A0

Appreciate=C2= =A0your guidance.

On Wed, May 29, 2024 at 1:38=E2=80=AFPM Laurenz Albe <<= a href=3D"mailto:laurenz.albe@cybertec.at">laurenz.albe@cybertec.at>= wrote:
On Wed, = 2024-05-29 at 01:34 +0530, yudhi s wrote:
> > The only way you can have no delay in replication AND no canceled= queries is
> > if you use two different standby servers with different settings = for
> > "max_standby_streaming_delay".=C2=A0 One of the server = is for HA, the other for
> > your long-running queries.
>
> When you suggest having different max_standby_streaming_delay for firs= t replica
> (say 10 sec for High availability) and second replica(say -1 for long = running queries).
> Do you also suggest=C2=A0 keeping "hot_feedback_standby" as = "OFF" for all the three
> instances i.e. master and both the replicas?

The parameter is ignored on the master.
It needs to be off on the standby that is running long queries.
For the other standby it probably doesn't matter if you are not running= any
queries on it.=C2=A0 I would leave "hot_standby_feedback =3D off"= there as well.

Actually, I would set "hot_standby =3D off" on the standby that i= s only used
for HA.


- I would leave "hot_standby_feedback" off everywhere.
- "max_standby_streaming_delay" should be -1 on the reporting sta= ndby and very
=C2=A0 low or 0 on the HA standby. It doesn't matter on the primary. - "statement_timeout" should be way lower on the first two nodes.=
- "idle_in_transaction_session_timeout" is good.
- I would leave "autovacuum_freeze_max_age" at the default settin= g but 100 million
=C2=A0 is ok too.

Yours,
Laurenz Albe
--000000000000dcbfcb061a1ea298--