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 1sA1gY-0072ym-N1 for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 06:12:20 +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 1sA1gY-008arI-OA for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 06:12:18 +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 1sA1gY-008ar2-AI for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 06:12:18 +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 1sA1gR-000KXP-AG for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 06:12:17 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-4df3d1076b0so2245213e0c.1 for ; Wed, 22 May 2024 23:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716444730; x=1717049530; 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=hUhNUGeuiOL+aUFIPH02RtjsqI0eQtEGuLLfj37qIOQ=; b=OauJMq3nOEDON5C60LX1dhO8QjaKsPDfV7bAhomnUnqCb9WKcLvxxG11hgx+wqiRD5 y4ckx88/VmJAUmXC+EtdWoLaj54xZ06SFlVNJ9jyEt2MEiCrssTiitf3KHJN4mgqDDYK 7rfYyG2dXjMO7cDYGt7wUz+i3xNYhw//TW9fzfJodg8Pl3ZaAT6GsK2Y7hM9KNoYvr9K wNyhrPRT6xP9f0Xu9hERJd0NM9QECdDXDLq9WMnGbAnp6EVaJhVFVqFZPDDe+NXyR1kB ykS1GGIVbpkxry6pcc6xSrEUuv6fx5v7zFLniAz7wJxO6lgGxoCPbrOzjJfb6Su5ulgG jmCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716444730; x=1717049530; 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=hUhNUGeuiOL+aUFIPH02RtjsqI0eQtEGuLLfj37qIOQ=; b=FROEcXUyd9kg2YO8JS0gm7kK5oGwoDdTF96+pq5Kq3Otx2+i3F151K7Ho3S5t3cmbd qoxTVKtExefp0T7gu5UV9/OCEV4u/jNjVGy1h0OZisc6ULEOvHZfg75NBNCOTDHI+Qrb cbFJb/ei51TA+8jt2MSTxQBIw7RmoUBe7dlCRJadd7H/omsIIM/wOGpRWbbVem5SJnPw 7ZHnVELTH8JTyUUwypmUdy5jorIy8gM7Tphic+0a6tylUn6P6+RuH1Kmb8IxGE7w9lSj 980YIHWWhX907WswGWNOc6bD1MagnqH/BO26D/T+AfLk7mgi3zAa4bkF43CmlnF/MdDg lclQ== X-Gm-Message-State: AOJu0YwMhkOK9TSQANcUvv+5N0iWKZGkRvnd7CJ1AmhZMUiPEqDsn08N A0ZkEQ+9odvIwOxE5XcWkfay0JymvCicWrp2QchkRvpDmRjGwbzzAYec4sZzjYCdltzrWz8M1Sw JbpFfvmQj6+dpUw38f8lHf/ihwmE= X-Google-Smtp-Source: AGHT+IH0WQ1vSB+q8eK3ISN+rMJBrxRdyplFcrjAtJlgIcpNzngJ8FtQ0+4HBqpn1ZX+GN4oGRzvHPL8LCfNXp5n1uA= X-Received: by 2002:a05:6122:8cb:b0:4df:1d06:eeb7 with SMTP id 71dfb90a1353d-4e215daeeb4mr4413534e0c.1.1716444729836; Wed, 22 May 2024 23:12:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: sud Date: Thu, 23 May 2024 11:41:58 +0530 Message-ID: Subject: Re: Long running query causing XID limit breach To: Muhammad Salahuddin Manzoor Cc: pgsql-general Content-Type: multipart/alternative; boundary="000000000000660cd8061918eeb0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000660cd8061918eeb0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 23, 2024 at 10:42=E2=80=AFAM Muhammad Salahuddin Manzoor < salahuddin.m@bitnine.net> wrote: > Greetings, > > Running `VACUUM table_name;` on a partitioned table will vacuum each > partition individually, not the whole table as a single unit. > > Yes, running `VACUUM table_name;` frequently on tables or partitions with > heavy DML is recommended. > > Regular `VACUUM` does not lock the table for reads or writes, so it won't > disrupt ongoing 24/7 data operations. > > "optimize autovacuum" > Yes. Adjust following parameters as per your system/environment > requirement > autovacuum_max_workers, > autovacuum_freeze_max_age , > autovacuum_vacuum_cost_delay > > Following need to be first tested thoroughly in a test environment. > Recommended Alert Threshold > Alert at 50% Usage: Set the alert threshold at 1 billion used XIDs. This > provides a significant buffer, giving you ample time to take corrective > action before reaching the critical limit. > > Calculation Rationale > Daily XID Usage: Approximately 4 billion rows per day implies high XID > consumption. > Buffer Time: At 1 billion XIDs, you would still have 1 billion XIDs > remaining, giving you roughly 12 hours to address the issue if your syste= m > consumes 200 million XIDs per hour. > > > Thank you so much. That helps. So apart from setting these alerts on "Maximumusedtxnids" and making the vacuum optimized by tweaking above parameters, should we also need to have monitoring in place to ensure the Vacuum is not taking longer as compared to its normal runtime and also if it's getting blocked/failed by something? Like for example in our case where the select query was running longer , so the vacuum must not be able to succeed every time it attempts, so is it really worth having that level of alerting? and also how can we get an idea regarding if the vacuum is not succeeding or getting failed etc to avoid such upcoming issues? --000000000000660cd8061918eeb0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, May 23, 2024 at 10:42=E2=80=AFAM = Muhammad Salahuddin Manzoor <salahuddin.m@bitnine.net> wrote:
Greetings,

Run= ning `VACUUM table_name;` on a partitioned table will vacuum each partition= individually, not the whole table as a single unit.

Yes, running `V= ACUUM table_name;` frequently on tables or partitions with heavy DML is rec= ommended.

Regular `VACUUM` does not lock the table for reads or writ= es, so it won't disrupt ongoing 24/7 data operations.

"opti= mize autovacuum"
Yes. Adjust following parameters as per your syste= m/environment requirement
autovacuum_max_workers,=C2=A0
autov= acuum_freeze_max_age ,=C2=A0
autovacuum_vacuum_cost_delay

= Following need to be first tested thoroughly in a test environment.
Reco= mmended Alert Threshold
Alert at 50% Usage: Set the alert threshold at 1= billion used XIDs. This provides a significant buffer, giving you ample ti= me to take corrective action before reaching the critical limit.

Cal= culation Rationale
Daily XID Usage: Approximately 4 billion rows per day= implies high XID consumption.
Buffer Time: At 1 billion XIDs, you would= still have 1 billion XIDs remaining, giving you roughly 12 hours to addres= s the issue if your system consumes 200 million XIDs per hour.

=


Thank you so much. That help= s.
So apart from setting these alerts on "Maximumusedtxnids" = and making the vacuum optimized by tweaking above parameters, should we als= o need to have monitoring in place to ensure=C2=A0the Vacuum is not taking = longer as compared to its normal runtime and also if it's getting block= ed/failed by something? Like for example in our case where the select query= was running longer , so the vacuum=C2=A0must not be able to succeed every = time it attempts, so is it really worth having=C2=A0that level of alerting?= =C2=A0 and also how can we get an idea regarding if the vacuum is not succe= eding or getting failed etc to avoid such upcoming issues?=C2=A0
=
--000000000000660cd8061918eeb0--